Skip to content

Commit 35cc737

Browse files
committed
Add for required fields when using only ModelValidator::add()
1 parent bce0eb3 commit 35cc737

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lib/Cake/Test/Case/View/Helper/FormHelperTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8007,6 +8007,32 @@ public function testFormInputRequiredDetection() {
80078007
);
80088008
$this->assertTags($result, $expected);
80098009
}
8010+
8011+
/**
8012+
* Test that required fields are created when only using ModelValidator::add().
8013+
*
8014+
* @return void
8015+
*/
8016+
public function testFormInputRequiredDetectionModelValidator() {
8017+
ClassRegistry::getObject('ContactTag')->validator()->add('iwillberequired', 'required', array('rule' => 'notEmpty'));
8018+
8019+
$this->Form->create('ContactTag');
8020+
$result = $this->Form->input('ContactTag.iwillberequired');
8021+
$expected = array(
8022+
'div' => array('class' => 'input text required'),
8023+
'label' => array('for' => 'ContactTagIwillberequired'),
8024+
'Iwillberequired',
8025+
'/label',
8026+
'input' => array(
8027+
'name' => 'data[ContactTag][iwillberequired]',
8028+
'type' => 'text',
8029+
'id' => 'ContactTagIwillberequired',
8030+
'required' => 'required'
8031+
),
8032+
'/div'
8033+
);
8034+
$this->assertTags($result, $expected);
8035+
}
80108036

80118037
/**
80128038
* testFormMagicInput method

0 commit comments

Comments
 (0)