Adds MacroableTrait to FormBuilder and HtmlBuilder

This commit is contained in:
Nicholas Ruunu committed 2014-02-27 11:45:39 +01:00
1 parent 50d7f44895
commit c0f9116999
2 files changed
+6 -76

No files matched your search

+3 -38
View File
@@ -2,9 +2,12 @@
use Illuminate\Routing\UrlGenerator;
use Illuminate\Session\Store as Session;
use Illuminate\Support\Traits\MacroableTrait;
class FormBuilder {
use MacroableTrait;
/**
* The HTML builder instance.
*
@@ -47,13 +50,6 @@ class FormBuilder {
*/
protected $labels = array();
/**
* The registered form builder macros.
*
* @var array
*/
protected $macros = array();
/**
* The reserved form open attributes.
*
@@ -730,18 +726,6 @@ class FormBuilder {
return '<button'.$this->html->attributes($options).'>'.$value.'</button>';
}
/**
* Register a custom form macro.
*
* @param string $name
* @param callable $macro
* @return void
*/
public function macro($name, $macro)
{
$this->macros[$name] = $macro;
}
/**
* Parse the form action method.
*
@@ -984,23 +968,4 @@ class FormBuilder {
return $this;
}
/**
* Dynamically handle calls to the form builder.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public function __call($method, $parameters)
{
if (isset($this->macros[$method]))
{
return call_user_func_array($this->macros[$method], $parameters);
}
throw new \BadMethodCallException("Method {$method} does not exist.");
}
}