/** * 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; } } }
/** * {@inheritDoc} */ public function submit($data) { if ($this->mode === self::FORM) { parent::submit($data); } else { Field::submit($data); } }