Adding interval to minute() attributes when timeformat = 24.

Tests added.
Closes #5428, refs #4641

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7711 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-10-07 16:57:22 +00:00
parent 11a29679e4
commit acce4fa54e
2 changed files with 25 additions and 12 deletions

View file

@ -278,7 +278,7 @@ class FormHelper extends AppHelper {
} }
} }
$out .= $this->submit($submit, $submitOptions); $out .= $this->submit($submit, $submitOptions);
} }
if (isset($this->params['_Token']) && !empty($this->params['_Token'])) { if (isset($this->params['_Token']) && !empty($this->params['_Token'])) {
$out .= $this->secure($this->fields); $out .= $this->secure($this->fields);
$this->fields = array(); $this->fields = array();
@ -1569,6 +1569,7 @@ class FormHelper extends AppHelper {
switch($timeFormat) { switch($timeFormat) {
case '24': case '24':
$selectMinuteAttr['interval'] = $interval;
$opt .= $this->hour($fieldName, true, $hour, $selectHourAttr, $showEmpty) . ':' . $opt .= $this->hour($fieldName, true, $hour, $selectHourAttr, $showEmpty) . ':' .
$this->minute($fieldName, $min, $selectMinuteAttr, $showEmpty); $this->minute($fieldName, $min, $selectMinuteAttr, $showEmpty);
break; break;

View file

@ -730,7 +730,7 @@ class FormHelperTest extends CakeTestCase {
$this->Form->create('Addresses'); $this->Form->create('Addresses');
$this->Form->input('Address.title'); $this->Form->input('Address.title');
$this->Form->input('Address.first_name'); $this->Form->input('Address.first_name');
$result = $this->Form->submit('Save', array('name' => 'save')); $result = $this->Form->submit('Save', array('name' => 'save'));
$expected = array( $expected = array(
'div' => array('class' => 'submit'), 'div' => array('class' => 'submit'),
@ -746,7 +746,7 @@ class FormHelperTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Form->end(null); $result = $this->Form->end(null);
$expected = array( $expected = array(
'fieldset' => array('style' => 'display:none;'), 'fieldset' => array('style' => 'display:none;'),
'input' => array( 'input' => array(
@ -760,7 +760,7 @@ class FormHelperTest extends CakeTestCase {
/** /**
* testFormSecurityMultipleInputFields method * testFormSecurityMultipleInputFields method
* *
* Test secure form creation with multiple row creation. Checks hidden, text, checkbox field types * Test secure form creation with multiple row creation. Checks hidden, text, checkbox field types
* *
* @access public * @access public
@ -850,7 +850,7 @@ class FormHelperTest extends CakeTestCase {
} }
/** /**
* testFormSecurityInputDisabledFields method * testFormSecurityInputDisabledFields method
* *
* Test single record form with disabled fields. * Test single record form with disabled fields.
* *
* @access public * @access public
@ -1184,7 +1184,7 @@ class FormHelperTest extends CakeTestCase {
} }
/** /**
* testMultipleInputValidation method * testMultipleInputValidation method
* *
* test multiple record form validation error display. * test multiple record form validation error display.
* *
* @access public * @access public
@ -1375,10 +1375,22 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/option value="23"/', $result[0]); $this->assertPattern('/option value="23"/', $result[0]);
$this->assertNoPattern('/option value="24"/', $result[0]); $this->assertNoPattern('/option value="24"/', $result[0]);
$result = $this->Form->input('Model.field', array('type' => 'time', 'timeFormat' => 12)); $result = $this->Form->input('Contact.created', array('type' => 'time', 'timeFormat' => 24));
$result = explode(':', $result); $result = explode(':', $result);
$this->assertPattern('/option value="12"/', $result[0]); $this->assertPattern('/option value="23"/', $result[0]);
$this->assertNoPattern('/option value="13"/', $result[0]); $this->assertNoPattern('/option value="24"/', $result[0]);
$result = $this->Form->input('Model.field', array('type' => 'time', 'timeFormat' => 24, 'interval' => 15));
$result = explode(':', $result);
$this->assertNoPattern('#<option value="12"[^>]*>12</option>#', $result[1]);
$this->assertNoPattern('#<option value="50"[^>]*>50</option>#', $result[1]);
$this->assertPattern('#<option value="15"[^>]*>15</option>#', $result[1]);
$result = $this->Form->input('Model.field', array('type' => 'time', 'timeFormat' => 12, 'interval' => 15));
$result = explode(':', $result);
$this->assertNoPattern('#<option value="12"[^>]*>12</option>#', $result[1]);
$this->assertNoPattern('#<option value="50"[^>]*>50</option>#', $result[1]);
$this->assertPattern('#<option value="15"[^>]*>15</option>#', $result[1]);
//related to ticket #5013 //related to ticket #5013
$result = $this->Form->input('Contact.date', array('type' => 'date', 'class' => 'customClass', 'onChange' => 'function(){}')); $result = $this->Form->input('Contact.date', array('type' => 'date', 'class' => 'customClass', 'onChange' => 'function(){}'));
@ -1415,8 +1427,8 @@ class FormHelperTest extends CakeTestCase {
'/div' '/div'
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$this->Form->data['Model']['0']['OtherModel']['field'] = 'My value'; $this->Form->data['Model']['0']['OtherModel']['field'] = 'My value';
$result = $this->Form->input('Model.0.OtherModel.field', array('id' => 'myId')); $result = $this->Form->input('Model.0.OtherModel.field', array('id' => 'myId'));
$expected = array( $expected = array(
@ -1876,7 +1888,7 @@ class FormHelperTest extends CakeTestCase {
$this->Form->data['Model']['text'] = 'test'; $this->Form->data['Model']['text'] = 'test';
$result = $this->Form->text('Model.text', array('id' => 'theID')); $result = $this->Form->text('Model.text', array('id' => 'theID'));
$this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'data[Model][text]', 'value' => 'test', 'id' => 'theID', 'class' => 'form-error'))); $this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'data[Model][text]', 'value' => 'test', 'id' => 'theID', 'class' => 'form-error')));
$this->Form->data['Model']['0']['OtherModel']['field'] = 'My value'; $this->Form->data['Model']['0']['OtherModel']['field'] = 'My value';
$result = $this->Form->text('Model.0.OtherModel.field', array('id' => 'myId')); $result = $this->Form->text('Model.0.OtherModel.field', array('id' => 'myId'));
$expected = array( $expected = array(