CodeIgniter Forums
Dynamic input field saving - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Dynamic input field saving (/showthread.php?tid=65895)



Dynamic input field saving - greenarrow - 08-09-2016

Newbie yet & this is the first time i'm working with dynamic fields, please check this video first.

http://www.screencast.com/t/Tl8jWxztdfG6


As i demonstrated i have this input field in my form (view).

Code:
<input type="text" name="fault[0]" placeholder="" class="form-control name_list" />  

<button type="button" name="add" id="add_fault_fld" class="btn btn-success">Add More</button>

what i need to know is, how can i store the values of these generating fields in database. there are other fields in this form as well i have already know & saving the results to the database using below model.

Model

PHP Code:
public function new_jobsheet_save() {

 $new_job_insert_db = array(

 'cus_name'=> $this->input->post('cusname'),
 'vehicle_number'=> $this->input->post('vehicles'),
 'date_in'=> $this->input->post('datein'),
 'date_out'=> $this->input->post('dateout'),
 'expected_completion'=> $this->input->post('datecom'),
 'mileage_in'=> $this->input->post('mileagein'),
 'mileage_out'=> $this->input->post('mileageout'),
 'service_advisor'=> $this->input->post('serviceadvisor'),
 
);

$insert $this->db->insert(' jobsheets'$new_job_insert_db);
    
 return $insert
;



  
in the model at the moment i'm not saving the data of joblist as you can see, because if i do so it only save default fields value but no others.

my table is "jobsheets"  on this table i have field called "faults_reported_by_customer" and this is where i need the data from my dynamic input fields needs to store. how can i achive this prefer some coding level guidance as i am clueless.

also is it possible to store is result in separate row of database? i really appreciate your help on this.


RE: Dynamic input field saving - InsiteFX - 08-09-2016

Your missing the value field for one.

Code:
<input type="text" name="fault[0]" placeholder="" class="form-control name_list" value="" />  

<button type="button" name="add" id="add_fault_fld" class="btn btn-success">Add More</button>



RE: Dynamic input field saving - greenarrow - 08-09-2016

(08-09-2016, 05:25 AM)InsiteFX Wrote: Your missing the value field for one.

Code:
<input type="text" name="fault[0]" placeholder="" class="form-control name_list" value="" />  

<button type="button" name="add" id="add_fault_fld" class="btn btn-success">Add More</button>

I am sorry what do you mean friend?


RE: Dynamic input field saving - InsiteFX - 08-09-2016

PHP Code:
<input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" /> 

Use the form_helper to set the value field.