Pass non-named routes through Form::open()
You can now pass non-named routes alongside urls to Form::open with the 'url' parameter. The UrlGenerator will validate if it's a valid url and will otherwise try to generate an url if it's a route. Signed-off-by: Dries Vints <dries.vints@gmail.com>
This commit is contained in:
1 parent
aaa4148a1f
commit
a904c422b7
1 file changed
+20
-1
+20
-1
@@ -530,7 +530,10 @@ class FormBuilder {
|
||||
// We will also check for a "route" or "action" parameter on the array so that
|
||||
// developers can easily specify a route or controller action when creating
|
||||
// a form providing a convenient interface for creating the form actions.
|
||||
if (isset($options['url'])) return $options['url'];
|
||||
if (isset($options['url']))
|
||||
{
|
||||
return $this->getUrlAction($options['url']);
|
||||
}
|
||||
|
||||
if (isset($options['route']))
|
||||
{
|
||||
@@ -548,6 +551,22 @@ class FormBuilder {
|
||||
return $this->url->current();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "url" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrlAction($options)
|
||||
{
|
||||
if (is_array($options))
|
||||
{
|
||||
return $this->url->to($options[0], array_slice($options, 1));
|
||||
}
|
||||
|
||||
return $this->url->to($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "route" option.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user