Tweaked HTML class to always try to add labels

Seems nesting HTML elements is a bit borked, will fix when I need to use it.
This commit is contained in:
Josh Sherman 2013-02-01 13:37:57 -05:00
parent 17609530e3
commit bf1c4db74e
2 changed files with 34 additions and 18 deletions

View file

@ -59,17 +59,25 @@ class HTML extends Object
{ {
$attributes = array('type' => $type); $attributes = array('type' => $type);
} }
if (isset($attributes['label'], $attributes['name']))
{
$label = $this->label(array('for' => $attributes['name']), $attributes['label']);
unset($attributes['label']);
return $label . $this->div($this->input($attributes));
}
} }
return $this->element($method, $attributes, $contents); if (isset($attributes['label'], $attributes['name']))
{
$label = $this->label(array('for' => $attributes['name']), $attributes['label']);
if (!isset($attributes['title']))
{
$attributes['title'] = $attributes['label'];
}
unset($attributes['label']);
return $label . $this->element('div', $this->$method($attributes));
}
else
{
return $this->element($method, $attributes, $contents);
}
} }
// {{{ Get Instance // {{{ Get Instance

26
jar.php
View file

@ -4218,17 +4218,25 @@ class HTML extends Object
{ {
$attributes = array('type' => $type); $attributes = array('type' => $type);
} }
if (isset($attributes['label'], $attributes['name']))
{
$label = $this->label(array('for' => $attributes['name']), $attributes['label']);
unset($attributes['label']);
return $label . $this->div($this->input($attributes));
}
} }
return $this->element($method, $attributes, $contents); if (isset($attributes['label'], $attributes['name']))
{
$label = $this->label(array('for' => $attributes['name']), $attributes['label']);
if (!isset($attributes['title']))
{
$attributes['title'] = $attributes['label'];
}
unset($attributes['label']);
return $label . $this->element('div', $this->$method($attributes));
}
else
{
return $this->element($method, $attributes, $contents);
}
} }
// {{{ Get Instance // {{{ Get Instance