Skip to content

Commit

Permalink
Add for required fields when using only ModelValidator::add()
Browse files Browse the repository at this point in the history
  • Loading branch information
thegallagher committed Jul 30, 2013
1 parent bce0eb3 commit 35cc737
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -8007,6 +8007,32 @@ public function testFormInputRequiredDetection() {
);
$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
Expand Down

0 comments on commit 35cc737

Please sign in to comment.