Skip to content
Permalink
Browse files

Pass required attribute into generated datetime options.

The required option was not copied onto the attributes for each select
element. This resulted in them not having the required attribute.

Refs #11699
  • Loading branch information...
markstory committed Feb 7, 2018
1 parent 887b3f0 commit 4cbe722fa592266d7da8173ca0a583eacf49472f
Showing with 20 additions and 0 deletions.
  1. +3 −0 src/View/Helper/FormHelper.php
  2. +17 −0 tests/TestCase/View/Helper/FormHelperTest.php
@@ -2434,6 +2434,9 @@ protected function _datetimeOptions($options)
if (isset($options['empty'][$type])) {
$options[$type]['empty'] = $options['empty'][$type];
}
if (isset($options['required']) && is_array($options[$type])) {
$options[$type]['required'] = $options['required'];
}
}
$hasYear = is_array($options['year']);
@@ -6986,6 +6986,23 @@ public function testControlDatetimePreEpoch()
$this->assertNotContains('value="00">00', $result);
}
/**
* test control() datetime & required attributes
*
* @return void
*/
public function testControlDatetimeRequired()
{
$result = $this->Form->control('birthday', [
'type' => 'date',
'required' => true
]);
$this->assertContains(
'<select name="birthday[year]" required="required"',
$result
);
}
/**
* testYearAutoExpandRange method
*

0 comments on commit 4cbe722

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