Permalink
Browse files

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

  • Loading branch information...
1 parent bce0eb3 commit 35cc737261f49697ed830a1647b1f2e891c44e2e @thegallagher thegallagher committed Jul 30, 2013
Showing with 26 additions and 0 deletions.
  1. +26 −0 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -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

0 comments on commit 35cc737

Please sign in to comment.