php - Handling a large number of semi related forms in CodeIgniter -


i have 20 page document 20 forms in it. it's organized sections.

section 1:  1.1 - form 1  1.2 - form 2  1.3 - form 3 section 2:  2.1 - form 1  ...etc... 

i have controller setup looks (for now):

class section extends ci_controller {     public function index($section_id) {         $this->section_model->_require_valid_section($section_id);          $data['view'] = "section/index";         $this->load->view('app/template', $data);     } } 

i need build views these 20 forms. each form has different data. 1 might have "name, email, phone" while next might have "person name, facility name, title" , aren't related. think silly have table each form (more forms come @ time), table this:

section | key     | value ------------------------- 1.1      name       randolph 1.1      phone      1111111111 2.1      person     junior 2.1      title      playa  

i'd know how set controller handle , route requests these forms.

would ideal create functions each one?

public function form_1_1() {    $this->section_model->save_1_1(); } public function form_1_2() {    $this->section_model->save_1_2(); } 

index() route requests via call_user_func() don't know if thats right way it.

you put hidden input in each form , inside controller function act on value of hidden field is.

add views in each form:

<input type="hidden" name="form_name" value="form_1" /> 

add controller:

$form_submitted = $this->input->post('form_name'); 

then use switch or if handle data based on $form_submitted variable.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -