mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Add for required fields when using only ModelValidator::add()
This commit is contained in:
parent
bce0eb37b4
commit
35cc737261
1 changed files with 26 additions and 0 deletions
|
@ -8007,6 +8007,32 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that required fields are created when only using ModelValidator::add().
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFormInputRequiredDetectionModelValidator() {
|
||||
ClassRegistry::getObject('ContactTag')->validator()->add('iwillberequired', 'required', array('rule' => 'notEmpty'));
|
||||
|
||||
$this->Form->create('ContactTag');
|
||||
$result = $this->Form->input('ContactTag.iwillberequired');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text required'),
|
||||
'label' => array('for' => 'ContactTagIwillberequired'),
|
||||
'Iwillberequired',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'name' => 'data[ContactTag][iwillberequired]',
|
||||
'type' => 'text',
|
||||
'id' => 'ContactTagIwillberequired',
|
||||
'required' => 'required'
|
||||
),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testFormMagicInput method
|
||||
|
|
Loading…
Reference in a new issue