title = $title; $this->request_url = $form->request_url; $this->request_method = $form->request_method; $this->fields = $form->getFields(); $this->missing = $form->getMissing(); $this->data = $form->getData(); $this->content_above = $form->content_above; $this->content_below = $form->content_below; } protected function html_content($exclude = [], $include = []) { if (!empty($this->title)) echo '

', $this->title, '

'; foreach ($this->_subtemplates as $template) $template->html_main(); echo '
'; if (isset($this->content_above)) echo $this->content_above; echo '
'; foreach ($this->fields as $field_id => $field) { // Either we have a blacklist if (!empty($exclude) && in_array($field_id, $exclude)) continue; // ... or a whitelist elseif (!empty($include) && !in_array($field_id, $include)) continue; // ... or neither (ha) $this->renderField($field_id, $field); } echo '
'; if (isset($this->content_below)) echo ' ', $this->content_below; echo '
'; if (!empty($this->title)) echo '
'; } protected function renderField($field_id, $field) { if (isset($field['before_html'])) echo ' ', $field['before_html'], '
'; if ($field['type'] != 'checkbox' && isset($field['label'])) echo '
missing) ? ' style="color: red"' : '', '>', $field['label'], '
'; elseif ($field['type'] == 'checkbox' && isset($field['header'])) echo '
missing) ? ' style="color: red"' : '', '>', $field['header'], '
'; echo '
'; if (isset($field['before'])) echo $field['before']; switch ($field['type']) { case 'select': echo ' '; break; case 'radio': foreach ($field['options'] as $value => $option) echo ' data[$field_id] == $value ? ' checked' : '', !empty($field['disabled']) ? ' disabled' : '', '> ', htmlentities($option); break; case 'checkbox': echo ' '; break; case 'textarea': echo ' '; break; case 'color': echo ' '; break; case 'numeric': echo ' '; break; case 'file': if (!empty($this->data[$field_id])) echo '
'; echo ' '; break; case 'text': case 'password': default: echo ' '; } if (isset($field['after'])) echo ' ', $field['after']; echo '
'; } }