Commit 34387fc4 by Taylor Otwell

Merge branch 'develop' of github.com:taylorotwell/laravel into develop

parents 30c83f26 8161e2c7
......@@ -3,6 +3,13 @@
class Form {
/**
* Stores labels names.
*
* @var array
*/
private static $labels = array();
/**
* Open a HTML form.
*
* @param string $action
......@@ -47,6 +54,16 @@ class Form {
}
/**
* Close a HTML form.
*
* @return void
*/
public static function close()
{
return '</form>'.PHP_EOL;
}
/**
* Generate a hidden field containing the current CSRF token.
*
* @return string
......@@ -72,6 +89,21 @@ class Form {
}
/**
* Create a HTML label element.
*
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public static function label($name, $value, $attributes = array())
{
static::$labels[] = $name;
return '<label for="'.$name.'"'.HTML::attributes($attributes).'>'.HTML::entities($value).'</label>'.PHP_EOL;
}
/**
* Create a HTML text input element.
*
* @param string $name
......@@ -190,6 +222,8 @@ class Form {
$attributes['checked'] = 'checked';
}
(in_array($name, static::$labels)) ? $attributes['id'] = $name : null;
return static::input($type, $name, $value, $attributes);
}
......@@ -204,6 +238,7 @@ class Form {
public static function textarea($name, $value = '', $attributes = array())
{
$attributes['name'] = $name;
(in_array($name, static::$labels)) ? $attributes['id'] = $name : null;
// -------------------------------------------------------
// Set the default number of rows.
......@@ -236,6 +271,7 @@ class Form {
public static function select($name, $options = array(), $selected = null, $attributes = array())
{
$attributes['name'] = $name;
(in_array($name, static::$labels)) ? $attributes['id'] = $name : null;
$html_options = array();
......@@ -265,6 +301,7 @@ class Form {
$attributes['type'] = $type;
$attributes['name'] = $name;
$attributes['value'] = $value;
(in_array($name, static::$labels)) ? $attributes['id'] = $name : null;
return '<input'.HTML::attributes($attributes).' />'.PHP_EOL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment