diff --git a/laravel/form.php b/laravel/form.php index 32aff7e4..bd16787d 100644 --- a/laravel/form.php +++ b/laravel/form.php @@ -7,28 +7,25 @@ class Form { * * @var array */ - protected static $labels = array(); + public static $labels = array(); /** - * The registered custom inputs + * The registered custom macros. * * @var array */ - - protected static $inputs = array(); - - /** - * Dynamically handle calls to custom registered inputs. - */ + public static $macros = array(); - public static function __callStatic($method, $parameters) + /** + * Registers a custom macro. + * + * @param string $name + * @param Closure $input + * @return void + */ + public static function macro($name, $macro) { - if (isset(static::$inputs[$method])) - { - return call_user_func_array(static::$inputs[$method], $parameters); - } - - throw new \Exception("Method [$method] does not exist."); + static::$macros[$name] = $macro; } /** @@ -74,8 +71,7 @@ class Form { // Since PUT and DELETE methods are not actually supported by HTML forms, // we'll create a hidden input element that contains the request method - // and set the actual request method to POST. Laravel will look for the - // hidden element to determine the request method. + // and set the actual request method variable to POST. if ($method == 'PUT' or $method == 'DELETE') { $append = static::hidden(Request::spoofer, $method); @@ -83,19 +79,6 @@ class Form { return '