fixes , correct label "for" in time input

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7188 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-06-14 21:40:01 +00:00
parent 2d3480a9ae
commit 8707c6861a
2 changed files with 38 additions and 22 deletions
cake
libs/view/helpers
tests/cases/libs/view/helpers

View file

@ -657,11 +657,11 @@ class FormHelper extends AppHelper {
}
if ($label !== false) {
$labelAttributes = array();
if (in_array($options['type'], array('date', 'datetime'))) {
$labelAttributes = $this->domId($labelAttributes, 'for');
if (in_array($options['type'], array('date', 'datetime'))) {
$labelAttributes['for'] .= 'Month';
} else if ($options['type'] === 'time') {
$labelAttributes['for'] .= 'Hour';
}
if (is_array($label)) {

View file

@ -2849,6 +2849,22 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$result = $this->Form->input('published', array('type' => 'time'));
$now = strtotime('now');
$expected = array(
'div' => array('class' => 'input time'),
'label' => array('for' => 'ContactPublishedHour'),
'Published',
'/label',
array('select' => array('name' => 'data[Contact][published][hour]', 'id' => 'ContactPublishedHour')),
'preg:/(?:<option value="([\d])+">[\d]+<\/option>[\r\n]*)*/',
array('option' => array('value' => date('h', $now), 'selected' => 'selected')),
date('g', $now),
'/option',
'*/select',
':',
);
$this->assertTags($result, $expected);
}
/**
* testFormDateTimeMulti method