_form = $form; $this->fields = array_keys($form->fields); } protected function _text($value) { return htmlspecialchars($value); } protected function _attr($attr=[]) { $out = ' '; foreach ($attr as $key=>$val) { if (is_array($val)) continue; // skip options etc if ($val===true) { $out .= $key . ' '; } else { $out .= $key . '="' . htmlspecialchars($val, ENT_QUOTES). '" '; } } return $out; } function open($attr=[]) { $attr = $attr + $this->_form->attr; return '
'; } function all() { $form = $this->_form; $out = $this->open(); foreach ($this->fields as $fieldName) { $out .= $this->label($fieldName); $out .= $this->field($fieldName); if (!empty($form->errors[$fieldName])) { // todo: nechceme spíš pole chyb? $out .= ' '; } } $out .= $this->close(); return $out; } function __toString() { return $this->all(); } }