Ejemplo n.º 1
0
 /**
  * Disables validation.
  *
  * @return self
  */
 public function disableValidation()
 {
     foreach ($this->fields->all() as $field) {
         if ($field instanceof Field\ChoiceFormField) {
             $field->disableValidation();
         }
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Removes a field from the form.
  *
  * @param string $name The field name
  */
 public function offsetUnset($name)
 {
     $this->fields->remove($name);
 }
Ejemplo n.º 3
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Unreachable field "0"
  */
 public function testFormRegistrySetArrayOnNotCompoundField()
 {
     $registry = new FormFieldRegistry();
     $registry->add($this->getFormFieldMock('bar'));
     $registry->set('bar', array('baz'));
 }
Ejemplo n.º 4
0
 public function testFormRegistrySetValues()
 {
     $registry = new FormFieldRegistry();
     $registry->add($f2 = $this->getFormFieldMock('foo[2]'));
     $registry->add($f3 = $this->getFormFieldMock('foo[3]'));
     $registry->add($fbb = $this->getFormFieldMock('foo[bar][baz]'));
     $f2->expects($this->exactly(2))->method('setValue')->with(2);
     $f3->expects($this->exactly(2))->method('setValue')->with(3);
     $fbb->expects($this->exactly(2))->method('setValue')->with('fbb');
     $registry->set('foo[2]', 2);
     $registry->set('foo[3]', 3);
     $registry->set('foo[bar][baz]', 'fbb');
     $registry->set('foo', array(2 => 2, 3 => 3, 'bar' => array('baz' => 'fbb')));
 }