Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Only create a route of a match is found
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed May 3, 2016
1 parent 4972e70 commit 99756f3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions code/template/filter/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,26 @@ protected function _initialize(ObjectConfig $config)
*/
public function filter(&$text, TemplateInterface $template)
{
$this->_addAction($text, $template->route());
$this->_addAction($text, $template);
$this->_addToken($text);
$this->_addQueryParameters($text);
}

/**
* Add the action if left empty
*
* @param string $text Template text
* @param string $action The action url
* @param string $text Template text
* @param TemplateInterface $template A template object
* @return TemplateFilterForm
*/
protected function _addAction(&$text, $action)
protected function _addAction(&$text, TemplateInterface $template)
{
// All: Add the action if left empty
if (preg_match_all('#<\s*form.*?action=""#sim', $text, $matches, PREG_SET_ORDER))
{
foreach ($matches as $match)
{
$str = str_replace('action=""', 'action="' . $action . '"', $match[0]);
$str = str_replace('action=""', 'action="' . $template->route() . '"', $match[0]);
$text = str_replace($match[0], $str, $text);
}
}
Expand Down

0 comments on commit 99756f3

Please sign in to comment.