Skip to content
Permalink
Browse files

Fixing FormHelper::input() label's for attribute when a datetime type…

… is created and dateFormat or timeFormat is set to NONE. Fixes #168
  • Loading branch information...
markstory committed Oct 15, 2009
1 parent 604b7e0 commit 082156f9a1842b3d3c5e0afca48c4dba69ccab12
Showing with 18 additions and 6 deletions.
  1. +10 −6 cake/libs/view/helpers/form.php
  2. +8 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -708,9 +708,13 @@ function input($fieldName, $options = array()) {
if ($label !== false) {
$labelAttributes = $this->domId(array(), 'for');
if (in_array($options['type'], array('date', 'datetime'))) {
$labelAttributes['for'] .= 'Month';
} else if ($options['type'] === 'time') {
if ($options['type'] === 'date' || $options['type'] === 'datetime') {
if (isset($options['dateFormat']) && $options['dateFormat'] === 'NONE') {
$labelAttributes['for'] .= 'Hour';
} else {
$labelAttributes['for'] .= 'Month';
}
} elseif ($options['type'] === 'time') {
$labelAttributes['for'] .= 'Hour';
}
@@ -764,10 +768,10 @@ function input($fieldName, $options = array()) {
unset($options['dateFormat']);
}
$type = $options['type'];
$before = $options['before'];
$type = $options['type'];
$before = $options['before'];
$between = $options['between'];
$after = $options['after'];
$after = $options['after'];
unset($options['type'], $options['before'], $options['between'], $options['after']);
switch ($type) {
@@ -1769,6 +1769,14 @@ function testInputDatetime() {
'/div'
);
$this->assertTags($result, $expected);
$this->Form->data = array('Contact' => array('created' => null));
$result = $this->Form->input('Contact.created', array('type' => 'datetime', 'dateFormat' => 'NONE'));
$this->assertPattern('/for\="ContactCreatedHour"/', $result);
$this->Form->data = array('Contact' => array('created' => null));
$result = $this->Form->input('Contact.created', array('type' => 'datetime', 'timeFormat' => 'NONE'));
$this->assertPattern('/for\="ContactCreatedMonth"/', $result);
}
/**
* Test generating checkboxes in a loop.

0 comments on commit 082156f

Please sign in to comment.
You can’t perform that action at this time.