Skip to content

Instantly share code, notes, and snippets.

@mjacobus
Created July 24, 2015 15:01
Show Gist options
  • Save mjacobus/890e3166cc09a2fff2bc to your computer and use it in GitHub Desktop.
Save mjacobus/890e3166cc09a2fff2bc to your computer and use it in GitHub Desktop.
/**
* Bind values to the bound object
*
* @param array $values
* @return mixed
*/
public function bindValues(array $values = array())
{
if (!is_object($this->object)) {
if ($this->baseFieldset === null || $this->baseFieldset->allowValueBinding() == false) {
// return;
}
}
if (!$this->hasValidated() && !empty($values)) {
$this->setData($values);
if (!$this->isValid()) {
return;
}
} elseif (!$this->isValid) {
return;
}
$filter = $this->getInputFilter();
switch ($this->bindAs) {
case FormInterface::VALUES_RAW:
$data = $filter->getRawValues();
break;
case FormInterface::VALUES_NORMALIZED:
default:
$data = $filter->getValues();
break;
}
$data = $this->prepareBindData($data, $this->data);
// If there is a base fieldset, only hydrate beginning from the base fieldset
if ($this->baseFieldset !== null) {
$data = $data[$this->baseFieldset->getName()];
$this->object = $this->baseFieldset->bindValues($data);
} else {
$this->object = parent::bindValues($data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment