How to create a register form in frontend of fuel cms?

How to create a register form in frontend of fuel cms?

Comments

  • edited 7:44PM
    If you are wanting to capture the data into a table, you can create your table and then wrap it with a FUEL model (extending base_module_model) and use the form_fields method. So for example, you could create a controller to view and process the form similar to the following (using version 0.93):
    class Register extends CI_Controller { function __construct() { parent::__construct(); } function index() { $this->load->library('form_builder'); $this->load->model('register_model'); if (!empty($_POST)) { if ($this->register_model->save($_POST)) { $this->session->set_flashdata('success', TRUE); redirect('register'); } } //register_model should extend the Base_module_model class (http://www.getfuelcms.com/user_guide/libraries/base_module_model) $fields = $this->register_model->form_fields(); $this->form_builder->set_fields($fields); // will set the values of the fields if there is an error... must be after set_fields $this->form_builder->set_field_values($_POST); $this->form_builder->display_errors = TRUE; // create a variable of $form to hold the rendered form output $vars['form'] = $this->form_builder->render(); // use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing // create a view file called "register.php" that contains a place to merge in the $form variable $page_init = array('location' => 'register'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->add_variables($vars); $this->fuel_page->render(); } }
    Other resources that may help:
    http://www.getfuelcms.com/user_guide/modules
    http://www.getfuelcms.com/user_guide/modules/tutorial
    http://www.getfuelcms.com/user_guide/libraries/form_builder
Sign In or Register to comment.