/** * @desc Displays the form * @return Template The template containing all the form elements which is ready to be displayed. */ public function display() { if ($this->enable_captcha_protection) { $this->move_captcha_protection_in_last_position(); } $template = $this->get_template_to_use(); $template->put_all(array('C_JS_NOT_ALREADY_INCLUDED' => !self::$js_already_included, 'C_HAS_REQUIRED_FIELDS' => self::$instance_id == 1 ? $this->has_required_fields() : false, 'C_TARGET' => !empty($this->target), 'FORMCLASS' => $this->css_class, 'TARGET' => $this->target, 'HTML_ID' => $this->html_id, 'L_REQUIRED_FIELDS' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'C_VALIDATION_ERROR' => count($this->validation_error_messages), 'TITLE_VALIDATION_ERROR_MESSAGE' => LangLoader::get_message('form.validation_error', 'status-messages-common'), 'METHOD' => $this->method)); foreach ($this->validation_error_messages as $error_message) { if (!empty($error_message)) { $template->assign_block_vars('validation_error_messages', array('ERROR_MESSAGE' => $error_message)); } } self::$js_already_included = true; foreach ($this->fieldsets as $fieldset) { $template->assign_block_vars('fieldsets', array(), array('FIELDSET' => $fieldset->display())); //Onsubmit constraints foreach ($fieldset->get_onsubmit_validations() as $constraints) { foreach ($constraints as $constraint) { $template->assign_block_vars('check_constraints', array('ONSUBMIT_CONSTRAINTS' => $constraint)); } } } if (count($this->buttons) > 0) { $buttons_fieldset = new FormFieldsetSubmit('fbuttons'); $buttons_fieldset->set_form_id($this->html_id); foreach ($this->buttons as $button) { $buttons_fieldset->add_element($button); } $template->assign_block_vars('fieldsets', array(), array('FIELDSET' => $buttons_fieldset->display())); } return $template; }