mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixed attributes being set for select elements in formHelper::dateTime() when $options[id] is specified. Closes #5013.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7306 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
80b6e027c1
commit
c25ed9016a
2 changed files with 14 additions and 0 deletions
|
@ -444,6 +444,7 @@ class FormHelper extends AppHelper {
|
|||
*
|
||||
* @param string $fieldName This should be "Modelname.fieldname", "Modelname/fieldname" is deprecated
|
||||
* @param string $text Text that will appear in the label field.
|
||||
* @param array $attributes Array of HTML attributes.
|
||||
* @return string The formatted LABEL element
|
||||
*/
|
||||
function label($fieldName = null, $text = null, $attributes = array()) {
|
||||
|
@ -1437,6 +1438,7 @@ class FormHelper extends AppHelper {
|
|||
// build out an array version
|
||||
foreach ($elements as $element) {
|
||||
$selectAttrName = 'select' . $element . 'Attr';
|
||||
${$selectAttrName} = $attributes;
|
||||
${$selectAttrName}['id'] = $attributes['id'] . $element;
|
||||
}
|
||||
} elseif (is_array($attributes['id'])) {
|
||||
|
|
|
@ -1214,7 +1214,19 @@ class FormHelperTest extends CakeTestCase {
|
|||
$result = explode(':', $result);
|
||||
$this->assertPattern('/option value="12"/', $result[0]);
|
||||
$this->assertNoPattern('/option value="13"/', $result[0]);
|
||||
|
||||
//related to ticket #5013
|
||||
$result = $this->Form->input('Contact.date', array('type' => 'date', 'class' => 'customClass', 'onChange' => 'function(){}'));
|
||||
$this->assertPattern('/class="customClass"/', $result);
|
||||
$this->assertPattern('/onChange="function\(\)\{\}"/', $result);
|
||||
|
||||
Configure::write('test', true);
|
||||
$result = $this->Form->input('Contact.date', array('type' => 'date', 'id' => 'customId', 'onChange' => 'function(){}'));
|
||||
$this->assertPattern('/id="customIdDay"/', $result);
|
||||
$this->assertPattern('/id="customIdMonth"/', $result);
|
||||
$this->assertPattern('/onChange="function\(\)\{\}"/', $result);
|
||||
Configure::write('test', false);
|
||||
|
||||
$result = $this->Form->input('Model.field', array('type' => 'datetime', 'timeFormat' => 24, 'id' => 'customID'));
|
||||
$this->assertPattern('/id="customIDDay"/', $result);
|
||||
$this->assertPattern('/id="customIDHour"/', $result);
|
||||
|
|
Loading…
Reference in a new issue