mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-01 07:09:46 +00:00
fixes #4912, 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:
parent
2d3480a9ae
commit
8707c6861a
2 changed files with 38 additions and 22 deletions
cake
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue