Esempio n. 1
0
 /**
  * @expectedException InvalidArgumentException
  * @expectedMessage Duplicate element exists with [first_name]
  */
 public function testDuplicateElement()
 {
     $fs = new Fieldset();
     $fs->setName('customers');
     $fs->addElement(new Element('first_name', 'text'));
     $fs->addElement(new Element('first_name', 'text'));
 }
Esempio n. 2
0
 public function makeFormConfig(FormConfig $config)
 {
     $validation_rules = $config->getValidationRules();
     $val = new LaravelValidator();
     $val->setRules($validation_rules);
     $form = new Form();
     $form->setAttribute('action', $config->getAction());
     $form->setTemplate($config->getTemplateInstance());
     $fields_data = $config->getFields();
     foreach ($fields_data as $fieldset_name => $fields) {
         $fs = new Fieldset();
         $fs->setName($fieldset_name);
         foreach ($fields as $field_name => $field_data) {
             $element = $this->makeElement($field_name, $field_data);
             $fs->addElement($element);
         }
         $form->addFieldset($fs);
     }
     $form->setValidator($val);
     return $form;
 }
Esempio n. 3
0
 /**
  * Add a fieldset
  * @param Fieldset $fieldset
  */
 public function addFieldset(Fieldset $fieldset)
 {
     $this->fieldsets[$fieldset->getName()] = $fieldset;
     return $this;
 }
Esempio n. 4
0
 public function testTemplateRender()
 {
     $t = m::mock('SH\\Formy\\TemplateInterface');
     $t->shouldReceive('setForm')->times(1);
     $t->shouldReceive('render')->times(1);
     $fs = new Fieldset();
     $fs->setName('customers');
     $form = new Form();
     $form->addFieldset($fs);
     $form->setTemplate($t);
     $form->render();
 }