private function getPostValue(Unit $unit) { foreach ($this->formSubmit->getPostValues() as $value) { if ($value->getKey() === $unit->getId()) { return $value->getValue(); } } }
/** * Compare the unit form field collection with post values. * * @param $renderApi * @param $unit * * @return boolean false if post values do not contain a unit form field */ private function compareFormUnits($renderApi, $unit) { $result = true; $this->collectUnitFormFields($renderApi, $unit); foreach ($this->formUnits as $formUnit) { $formValues = $formUnit->getFormValues(); // workaround to catch non-required not selected checkboxes if (!isset($formValues['enableRequired']) || !$formValues['enableRequired']) { $found = true; } else { $found = array_filter($this->formSubmit->getPostValues(), function ($postValue) use(&$formUnit) { return $postValue->getKey() === $formUnit->getId(); }); } if (!$found) { $result = false; break; } } return $result; }