/** * output the header content of the form */ public function outputHeader() { if (isset($this->options['attributes'])) { $attrs = $this->options['attributes']; } else { $attrs = array(); } echo '<form'; if (preg_match('#^https?://#', $this->_action)) { $urlParams = $this->_actionParams; $attrs['action'] = $this->_action; } else { $url = \jUrl::get($this->_action, $this->_actionParams, 2); // returns the corresponding jurl $urlParams = $url->params; $attrs['action'] = $url->getPath(); } $attrs['method'] = $this->options['method']; $attrs['id'] = $this->_name; if ($this->_form->hasUpload()) { $attrs['enctype'] = "multipart/form-data"; } $this->_outputAttr($attrs); echo '>'; $this->rootWidget->outputHeader($this); $hiddens = ''; foreach ($urlParams as $p_name => $p_value) { $hiddens .= '<input type="hidden" name="' . $p_name . '" value="' . htmlspecialchars($p_value) . '"' . $this->_endt . "\n"; } foreach ($this->_form->getHiddens() as $ctrl) { if (!$this->_form->isActivated($ctrl->ref)) { continue; } $hiddens .= '<input type="hidden" name="' . $ctrl->ref . '" id="' . $this->_name . '_' . $ctrl->ref . '" value="' . htmlspecialchars($this->_form->getData($ctrl->ref)) . '"' . $this->_endt . "\n"; } if ($this->_form->securityLevel) { $tok = $this->_form->createNewToken(); $hiddens .= '<input type="hidden" name="__JFORMS_TOKEN__" value="' . $tok . '"' . $this->_endt . "\n"; } if ($hiddens) { echo '<div class="jforms-hiddens">', $hiddens, '</div>'; } $this->outputErrors(); }
/** * output the header content of the form */ public function outputHeader() { if (isset($this->options['attributes'])) { $attrs = $this->options['attributes']; } else { $attrs = array(); } echo '<form'; if (preg_match('#^https?://#', $this->_action)) { $urlParams = $this->_actionParams; $attrs['action'] = $this->_action; } else { $url = \jUrl::get($this->_action, $this->_actionParams, 2); // returns the corresponding jurl $urlParams = $url->params; $attrs['action'] = $url->getPath(); } $attrs['method'] = $this->options['method']; $attrs['id'] = $this->_name; if ($this->_form->hasUpload()) { $attrs['enctype'] = "multipart/form-data"; } $this->_outputAttr($attrs); echo '>'; $this->rootWidget->outputHeader($this); $hiddens = ''; foreach ($urlParams as $p_name => $p_value) { $hiddens .= '<input type="hidden" name="' . $p_name . '" value="' . htmlspecialchars($p_value) . '"' . $this->_endt . "\n"; } foreach ($this->_form->getHiddens() as $ctrl) { if (!$this->_form->isActivated($ctrl->ref)) { continue; } $hiddens .= '<input type="hidden" name="' . $ctrl->ref . '" id="' . $this->_name . '_' . $ctrl->ref . '" value="' . htmlspecialchars($this->_form->getData($ctrl->ref)) . '"' . $this->_endt . "\n"; } if ($this->_form->securityLevel) { $tok = $this->_form->createNewToken(); $hiddens .= '<input type="hidden" name="__JFORMS_TOKEN__" value="' . $tok . '"' . $this->_endt . "\n"; } if ($hiddens) { echo '<div class="jforms-hiddens">', $hiddens, '</div>'; } $errors = $this->_form->getContainer()->errors; if (count($errors)) { $ctrls = $this->_form->getControls(); echo '<ul id="' . $this->_name . '_errors" class="jforms-error-list">'; $errRequired = ''; foreach ($errors as $cname => $err) { if (!$this->_form->isActivated($ctrls[$cname]->ref)) { continue; } if ($err === \jForms::ERRDATA_REQUIRED) { if ($ctrls[$cname]->alertRequired) { echo '<li>', $ctrls[$cname]->alertRequired, '</li>'; } else { echo '<li>', \jLocale::get('jelix~formserr.js.err.required', $ctrls[$cname]->label), '</li>'; } } else { if ($err === \jForms::ERRDATA_INVALID) { if ($ctrls[$cname]->alertInvalid) { echo '<li>', $ctrls[$cname]->alertInvalid, '</li>'; } else { echo '<li>', \jLocale::get('jelix~formserr.js.err.invalid', $ctrls[$cname]->label), '</li>'; } } elseif ($err === \jForms::ERRDATA_INVALID_FILE_SIZE) { echo '<li>', \jLocale::get('jelix~formserr.js.err.invalid.file.size', $ctrls[$cname]->label), '</li>'; } elseif ($err === \jForms::ERRDATA_INVALID_FILE_TYPE) { echo '<li>', \jLocale::get('jelix~formserr.js.err.invalid.file.type', $ctrls[$cname]->label), '</li>'; } elseif ($err === \jForms::ERRDATA_FILE_UPLOAD_ERROR) { echo '<li>', \jLocale::get('jelix~formserr.js.err.file.upload', $ctrls[$cname]->label), '</li>'; } elseif ($err != '') { echo '<li>', $err, '</li>'; } } } echo '</ul>'; } }