It looks like you're new here. If you want to get involved, click one of these buttons!
// build the form
$fields = array();
$fields['name'] = array('label' => 'Contact Name', 'required' => TRUE, 'class' => 'input left');
$fields['company'] = array('label' => 'Company', 'required' => TRUE, 'class' => 'input left');
$fields['address'] = array('label' => 'Address', 'required' => TRUE, 'class' => 'input left');
$fields['phone'] = array('label' => 'Phone', 'required' => FALSE, 'class' => 'input left');
$fields['fax'] = array('label' => 'FAX', 'required' => FALSE, 'class' => 'input left');
$fields['email'] = array('label' => 'Email', 'required' => TRUE, 'class' => 'input left');
$fields['inspection'] = array('label' => 'Inspection and Estimate Required by When?', 'required' => TRUE, 'class' => 'input left');
$fields['location'] = array('label' => 'Name of Location', 'required' => TRUE, 'class' => 'input left');
$fields['address'] = array('label' => 'Address', 'required' => TRUE, 'class' => 'input left');
$fields['contactName'] = array('label' => 'Contact Name', 'required' => TRUE, 'class' => 'input left');
$fields['phoneNum'] = array('label' => 'Phone Number', 'required' => FALSE, 'class' => 'input left');
$fields['access'] = array('label' => 'Access', 'required' => TRUE, 'class' => 'input left');
$fields['reason'] = array('label' => 'Reason for Estimate', 'required' => TRUE, 'class' => 'input left');
$fields['comments'] = array('label' => 'Comments', 'required' => TRUE, 'class' => 'input left');
$this->form_builder->set_fields($fields);
//$this->form_builder->render($fields);
// will set the values of the fields if there is an error... must be after set_fields
$this->form_builder->set_validator($this->validator);
$this->form_builder->set_field_values($_POST);
$vars['form'] = $this->form_builder->render();
Comments
Is it possible to build the form using 2 separate sections and then use both of them like this? If so, how would I do that in the controller?
<fieldset> <legend>First Section</legend> <?php echo $form; ?> </fieldset> <fieldset> <legend>Second Section</legend> <?php echo $form2; ?> </fieldset>
$this->form_builder->use_form_tag = FALSE; $this->form_builder->set_fields($fields1); $vars['form1'] = $this->form_builder->render(); $this->form_builder->set_fields($fields1); $vars['form2'] = $this->form_builder->render();
I've created a custom view based on the module_create_edit layout but I can't figure out where or how to insert the logic to double up the form.
Is creating a seperate controller the only way?
However, the next major release we are working on will allow you to create different fieldsets as well as tabs to group fields together. Look for something at the end of this month.
Why is that?
My controller code:
$fields = array(); $fields['registeredName'] = array('label'=>'Registered Name', 'size' => 100, 'required' => TRUE); $fields['registrationNo'] = array('label'=>'Registration No.', 'size' => 60, 'required' => TRUE); $fields['vatNo'] = array('label'=>'Vat No.', 'size' => 60, 'required' => TRUE); $fields['activity'] = array('label'=>'Main Activity', 'type' => 'select', 'options' => array('select' => 'Select your job title', 'Supplier' => 'Supplier', 'Transporter' => 'Transporter', 'Trader' => 'Trader', 'Broker' => 'Broker'), 'required' => TRUE); $fields1 = array(); $fields1['phaddr1'] = array('label'=>'Address Line 1', 'required' => TRUE); $fields1['phaddr2'] = array('label'=>'Address Line 2', 'required' => TRUE); $fields1['phsuburb'] = array('label'=>'Suburb', 'required' => TRUE); $fields1['phtown'] = array('label'=>'Town/City', 'required' => TRUE); $fields1['phpostcode'] = array('label'=>'Post Code', 'required' => TRUE); $this->form_builder->use_form_tag = FALSE; $this->form_builder->set_validator($this->validator); $this->form_builder->set_field_values($_POST); $this->form_builder->display_errors = TRUE; $this->form_builder->required_text = '<span class="required">*</span>Required fields'; $this->form_builder->set_fields($fields); $vars['form'] = $this->form_builder->render(); $this->form_builder->set_fields($fields1); $vars['form1'] = $this->form_builder->render(); $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();
What is the advantage of using form builder instead of just using codeigniter's form class in my view and create the fields in the view instead of in the controeller?
$fields = parent::form_fields($values); $CI =& get_instance();
To this
$CI =& get_instance(); $fields = array();
fieldsets work perfectly. The form field values are filling correctly as well. What's the difference between the 2 and are there any disadvantages to doing it that way?
http://forum.getfuelcms.com/discussion/1468/using-fieldset-in-the-cms#Item_2