/** * Adds the control identified by name. * * IF control is file then form enctype is changed to multipart. * * @return Form itself */ function addControl(IFormControl $control) { $name = $control->getName(); Assert::isFalse(isset($this->controls[$name]), 'control with name %s already exists', $name); $this->controls[$name] = $control; if ($control instanceof FileFormControl || $control instanceof FileFormControlSet) { $this->setEnctype(new FormEnctype(FormEnctype::MULTIPART)); } return $this; }
private static function dumpControlError(IFormControl $control) { if (!$control->hasError()) { return ''; } if ($control instanceof FormControlSet && $control->hasError(FormControlError::WRONG)) { $message = '<ul>'; foreach ($control as $innerControl) { $message .= self::dumpControlError($innerControl); } $message .= '</ul>'; } else { $message = $control->getErrorMessage(); } return '<li>' . $control->getName() . (($label = $control->getLabel()) ? " ({$label})" : '') . ' is ' . $control->getError() . ': <i>' . $message . '</i></li>'; }