Add for required fields when using only ModelValidator::add()

This commit is contained in:
David Gallagher 2013-07-30 11:11:49 +10:00
parent bce0eb37b4
commit 35cc737261

View file

@ -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