Exemplo n.º 1
0
 public function testValidation()
 {
     $val = m::mock('SH\\Formy\\ValidationInterface')->shouldReceive('setForm')->times(1)->shouldReceive('validate')->times(1)->getMock();
     $form = new Form();
     $form->setValidator($val);
     $form->validate();
 }
Exemplo 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;
 }