diff --git a/system/form.php b/system/form.php index 79f17a719..96b5b39dd 100644 --- a/system/form.php +++ b/system/form.php @@ -2,6 +2,13 @@ class Form { + /** + * Stores lables names. + * + * @var array + */ + private static $labels = array(); + /** * Open a HTML form. * @@ -81,6 +88,8 @@ class Form { */ public static function label($name, $value, $attributes = array()) { + static::$labels[] = $name; + return ''.PHP_EOL; } @@ -202,6 +211,8 @@ class Form { { $attributes['checked'] = 'checked'; } + + (in_array($name, static::$labels)) ? $attributes['id'] = $name : null; return static::input($type, $name, $value, $attributes); } @@ -217,6 +228,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. @@ -249,6 +261,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(); @@ -278,6 +291,7 @@ class Form { $attributes['type'] = $type; $attributes['name'] = $name; $attributes['value'] = $value; + (in_array($name, static::$labels)) ? $attributes['id'] = $name : null; return ''.PHP_EOL; }