bind() 공개 메소드

Binds POST data to the field, transforms and validates it.
public bind ( string | array $taintedData ) : boolean
$taintedData string | array The POST data
리턴 boolean Whether the form is valid
예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function bind($data)
 {
     if ($this->mode === self::GROUP) {
         parent::bind($data);
     } else {
         Field::bind($data);
     }
 }
예제 #2
0
 public function bind($taintedData)
 {
     if (is_null($taintedData)) {
         $taintedData = array();
     }
     foreach ($this as $name => $field) {
         if (!isset($taintedData[$name]) && $this->getOption('modifiable') && $name != '$$key$$') {
             $this->remove($name);
         }
     }
     foreach ($taintedData as $name => $value) {
         if (!isset($this[$name]) && $this->getOption('modifiable')) {
             $this->add($this->newField($name, $name));
         }
     }
     return parent::bind($taintedData);
 }
예제 #3
0
 public function bind($taintedData)
 {
     $this->removedFields = array();
     if (null === $taintedData) {
         $taintedData = array();
     }
     foreach ($this as $name => $field) {
         if (!isset($taintedData[$name]) && $this->getOption('modifiable') && '$$key$$' != $name) {
             $this->remove($name);
             $this->removedFields[] = $name;
         }
     }
     foreach ($taintedData as $name => $value) {
         if (!isset($this[$name]) && $this->getOption('modifiable')) {
             $this->add($this->newField($name, $name));
         }
     }
     parent::bind($taintedData);
 }
예제 #4
0
파일: Form.php 프로젝트: notbrain/symfony
 /**
  * Binds the form with the given data.
  *
  * @param  array $taintedData  The data to bind to the form
  * @return boolean             Whether the form is valid
  */
 protected function doBind(array $taintedData)
 {
     parent::bind($taintedData);
 }
예제 #5
0
 public function testBindWithoutPriorSetData()
 {
     return;
     // TODO
     $field = $this->createMockField('firstName');
     $field->expects($this->any())->method('getData')->will($this->returnValue('Bernhard'));
     $group = new FieldGroup('author');
     $group->add($field);
     $group->bind(array('firstName' => 'Bernhard'));
     $this->assertEquals(array('firstName' => 'Bernhard'), $group->getData());
 }