mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +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
|
@ -81,7 +81,7 @@ class FormHelper extends AppHelper {
|
|||
* 'type' Form method defaults to POST
|
||||
* 'action' The Action the form submits to. Can be a string or array,
|
||||
* 'url' The url the form submits to. Can be a string or a url array,
|
||||
* 'default' Allows for the creation of Ajax forms.
|
||||
* 'default' Allows for the creation of Ajax forms.
|
||||
* 'onsubmit' Used with 'default' to create ajax forms.
|
||||
*
|
||||
* @return string An formatted opening FORM tag.
|
||||
|
@ -382,7 +382,7 @@ class FormHelper extends AppHelper {
|
|||
* @param array $options Rendering options for <div /> wrapper tag
|
||||
* 'escape' bool Whether or not to html escape the contents of the error.
|
||||
* 'wrap' mixed Whether or not the error message should be wrapped in a div. If a string, will be used as the HTML tag to use.
|
||||
* 'class' string The classname for the error message
|
||||
* 'class' string The classname for the error message
|
||||
* @return string If there are errors this method returns an error message, otherwise null.
|
||||
* @access public
|
||||
*/
|
||||
|
@ -657,11 +657,11 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if ($label !== false) {
|
||||
$labelAttributes = array();
|
||||
|
||||
$labelAttributes = $this->domId($labelAttributes, 'for');
|
||||
if (in_array($options['type'], array('date', 'datetime'))) {
|
||||
$labelAttributes = $this->domId($labelAttributes, 'for');
|
||||
$labelAttributes['for'] .= 'Month';
|
||||
} else if ($options['type'] === 'time') {
|
||||
$labelAttributes['for'] .= 'Hour';
|
||||
}
|
||||
|
||||
if (is_array($label)) {
|
||||
|
@ -707,13 +707,13 @@ class FormHelper extends AppHelper {
|
|||
$timeFormat = $options['timeFormat'];
|
||||
unset($options['timeFormat']);
|
||||
}
|
||||
|
||||
|
||||
$dateFormat = 'MDY';
|
||||
if (isset($options['dateFormat'])) {
|
||||
$dateFormat = $options['dateFormat'];
|
||||
unset($options['dateFormat']);
|
||||
}
|
||||
|
||||
|
||||
$type = $options['type'];
|
||||
$before = $options['before'];
|
||||
$between = $options['between'];
|
||||
|
@ -1236,7 +1236,7 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (strlen($selected) > 2) {
|
||||
$selected = date('m', strtotime($selected));
|
||||
} elseif ($selected === false) {
|
||||
|
@ -1246,7 +1246,7 @@ class FormHelper extends AppHelper {
|
|||
$attributes = array_merge($defaults, (array) $attributes);
|
||||
$monthNames = $attributes['monthNames'];
|
||||
unset($attributes['monthNames']);
|
||||
|
||||
|
||||
return $this->select($fieldName . ".month", $this->__generateOptions('month', array('monthNames' => $monthNames)), $selected, $attributes, $showEmpty);
|
||||
}
|
||||
/**
|
||||
|
@ -1420,7 +1420,7 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$elements = array('Day','Month','Year','Hour','Minute','Meridian');
|
||||
$defaults = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true);
|
||||
$attributes = array_merge($defaults, (array) $attributes);
|
||||
|
|
|
@ -2332,7 +2332,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField'))
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$result = $this->Form->checkbox('Model.field', array('checked' => 'checked'));
|
||||
$expected = array(
|
||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
||||
|
@ -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
|
||||
|
@ -3661,7 +3677,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testGetFormCreate method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -3681,7 +3697,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testEditFormWithData method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -3715,7 +3731,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testFormMagicInput method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -3863,7 +3879,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testForMagicInputNonExistingNorValidated method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -3907,7 +3923,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testFormMagicInputLabel method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -3990,7 +4006,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testFormEnd method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -4053,7 +4069,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testMultipleFormWithIdFields method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -4071,7 +4087,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* testDbLessModel method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -4104,7 +4120,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
@ -4122,8 +4138,8 @@ class FormHelperTest extends CakeTestCase {
|
|||
}
|
||||
/**
|
||||
* sortFields method
|
||||
*
|
||||
* @param mixed $fields
|
||||
*
|
||||
* @param mixed $fields
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue