コード例 #1
0
ファイル: Form.php プロジェクト: noelg/symfony-demo
 /**
  * Binds POST data to the field, transforms and validates it.
  *
  * @param  string|array $data  The POST data
  */
 public function submit($data)
 {
     if (null === $data) {
         $data = array();
     }
     if (!is_array($data)) {
         throw new UnexpectedTypeException($data, 'array');
     }
     // remember for later
     $submittedData = $data;
     foreach ($this->fields as $key => $field) {
         if (!isset($data[$key])) {
             $data[$key] = null;
         }
     }
     $data = $this->preprocessData($data);
     foreach ($data as $key => $value) {
         if ($this->has($key)) {
             $this->fields[$key]->submit($value);
         }
     }
     $data = $this->getTransformedData();
     $this->writeObject($data);
     // set and reverse transform the data
     parent::submit($data);
     $this->extraFields = array();
     foreach ($submittedData as $key => $value) {
         if (!$this->has($key)) {
             $this->extraFields[] = $key;
         }
     }
 }
コード例 #2
0
ファイル: HybridField.php プロジェクト: rooster/symfony
 /**
  * {@inheritDoc}
  */
 public function submit($data)
 {
     if ($this->mode === self::FORM) {
         parent::submit($data);
     } else {
         Field::submit($data);
     }
 }