|
@@ -8,7 +8,7 @@ class Form {
|
|
|
* @var array
|
|
|
*/
|
|
|
public static $labels = array();
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* The registered custom macros.
|
|
|
*
|
|
@@ -16,13 +16,13 @@ class Form {
|
|
|
*/
|
|
|
public static $macros = array();
|
|
|
|
|
|
- /**
|
|
|
- * Registers a custom macro.
|
|
|
- *
|
|
|
- * @param string $name
|
|
|
- * @param Closure $input
|
|
|
- * @return void
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * Registers a custom macro.
|
|
|
+ *
|
|
|
+ * @param string $name
|
|
|
+ * @param Closure $input
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function macro($name, $macro)
|
|
|
{
|
|
|
static::$macros[$name] = $macro;
|
|
@@ -56,7 +56,7 @@ class Form {
|
|
|
$method = strtoupper($method);
|
|
|
|
|
|
$attributes['method'] = static::method($method);
|
|
|
-
|
|
|
+
|
|
|
$attributes['action'] = static::action($action, $https);
|
|
|
|
|
|
// If a character encoding has not been specified in the attributes, we will
|
|
@@ -128,7 +128,7 @@ class Form {
|
|
|
* @param array $attributes
|
|
|
* @param bool $https
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function open_for_files($action = null, $method = 'POST', $attributes = array(), $https = null)
|
|
|
{
|
|
|
$attributes['enctype'] = 'multipart/form-data';
|
|
@@ -143,7 +143,7 @@ class Form {
|
|
|
* @param string $method
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function open_secure_for_files($action = null, $method = 'POST', $attributes = array())
|
|
|
{
|
|
|
return static::open_for_files($action, $method, $attributes, true);
|
|
@@ -181,7 +181,7 @@ class Form {
|
|
|
* @param string $value
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function label($name, $value, $attributes = array())
|
|
|
{
|
|
|
static::$labels[] = $name;
|
|
@@ -209,7 +209,7 @@ class Form {
|
|
|
* @param mixed $value
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function input($type, $name, $value = null, $attributes = array())
|
|
|
{
|
|
|
$name = (isset($attributes['name'])) ? $attributes['name'] : $name;
|
|
@@ -240,7 +240,7 @@ class Form {
|
|
|
* @param string $name
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function password($name, $attributes = array())
|
|
|
{
|
|
|
return static::input('password', $name, null, $attributes);
|
|
@@ -266,7 +266,7 @@ class Form {
|
|
|
* @param string $value
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function search($name, $value = null, $attributes = array())
|
|
|
{
|
|
|
return static::input('search', $name, $value, $attributes);
|
|
@@ -279,7 +279,7 @@ class Form {
|
|
|
* @param string $value
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function email($name, $value = null, $attributes = array())
|
|
|
{
|
|
|
return static::input('email', $name, $value, $attributes);
|
|
@@ -305,7 +305,7 @@ class Form {
|
|
|
* @param string $value
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function url($name, $value = null, $attributes = array())
|
|
|
{
|
|
|
return static::input('url', $name, $value, $attributes);
|
|
@@ -318,12 +318,12 @@ class Form {
|
|
|
* @param string $value
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function number($name, $value = null, $attributes = array())
|
|
|
{
|
|
|
return static::input('number', $name, $value, $attributes);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Create a HTML date input element.
|
|
|
*
|
|
@@ -331,7 +331,7 @@ class Form {
|
|
|
* @param string $value
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function date($name, $value = null, $attributes = array())
|
|
|
{
|
|
|
return static::input('date', $name, $value, $attributes);
|
|
@@ -343,7 +343,7 @@ class Form {
|
|
|
* @param string $name
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function file($name, $attributes = array())
|
|
|
{
|
|
|
return static::input('file', $name, null, $attributes);
|
|
@@ -386,18 +386,18 @@ class Form {
|
|
|
* @param string $selected
|
|
|
* @param array $attributes
|
|
|
* @return string
|
|
|
- */
|
|
|
+ */
|
|
|
public static function select($name, $options = array(), $selected = null, $attributes = array())
|
|
|
{
|
|
|
$attributes['id'] = static::id($name, $attributes);
|
|
|
-
|
|
|
+
|
|
|
$attributes['name'] = $name;
|
|
|
|
|
|
$html = array();
|
|
|
|
|
|
foreach ($options as $value => $display)
|
|
|
{
|
|
|
- if (is_array($display))
|
|
|
+ if (is_array($display))
|
|
|
{
|
|
|
$html[] = static::optgroup($display, $value, $selected);
|
|
|
}
|
|
@@ -607,12 +607,12 @@ class Form {
|
|
|
*/
|
|
|
public static function __callStatic($method, $parameters)
|
|
|
{
|
|
|
- if (isset(static::$macros[$method]))
|
|
|
- {
|
|
|
- return call_user_func_array(static::$macros[$method], $parameters);
|
|
|
- }
|
|
|
-
|
|
|
- throw new \Exception("Method [$method] does not exist.");
|
|
|
+ if (isset(static::$macros[$method]))
|
|
|
+ {
|
|
|
+ return call_user_func_array(static::$macros[$method], $parameters);
|
|
|
+ }
|
|
|
+
|
|
|
+ throw new \Exception("Method [$method] does not exist.");
|
|
|
}
|
|
|
|
|
|
}
|