/** * Parse. */ private function parse() { // form name $formName = 'form' . $this->item['id']; $this->tpl->assign('formName', $formName); $this->tpl->assign('formAction', $this->createAction() . '#' . $formName); $this->tpl->assign('successMessage', false); // got fields if (!empty($this->fieldsHTML)) { // value of the submit button $submitValue = ''; // loop html fields foreach ($this->fieldsHTML as &$field) { if ($field['type'] == 'heading' || $field['type'] == 'paragraph') { $field['plaintext'] = true; } elseif ($field['type'] == 'checkbox' || $field['type'] == 'radiobutton') { // name (prefixed by type) $name = $field['type'] == 'checkbox' ? 'chk' . \SpoonFilter::toCamelCase($field['name']) : 'rbt' . \SpoonFilter::toCamelCase($field['name']); // rebuild so the html is stored in a general name (and not rbtName) foreach ($field['html'] as &$item) { $item['field'] = $item[$name]; } // multiple items $field['multiple'] = true; } elseif ($field['type'] == 'submit') { $submitValue = $field['html']; } else { $field['simple'] = true; } // errors (only for form elements) if (isset($field['simple']) || isset($field['multiple'])) { $field['error'] = $this->frm->getField($field['name'])->getErrors(); } } // assign $this->tpl->assign('submitValue', $submitValue); $this->tpl->assign('fields', $this->fieldsHTML); // parse form $this->frm->parse($this->tpl); $this->tpl->assign('formToken', $this->frm->getToken()); // assign form error $this->tpl->assign('error', $this->frm->getErrors() != '' ? $this->frm->getErrors() : false); } }