From a904c422b71da942fc0afff0008c7b5ae7d64986 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 6 Mar 2013 12:17:13 +0100 Subject: [PATCH] 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 --- FormBuilder.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/FormBuilder.php b/FormBuilder.php index f2c9365..de04070 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -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. *