HI guys how can i use same form for edit and add data into database? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: HI guys how can i use same form for edit and add data into database? (/showthread.php?tid=17509) Pages:
1
2
|
HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]Waqar[/eluser] I want to use one form for both edit and delete data into database but i am not understanding how I can do that? HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]pistolPete[/eluser] Insert and update in the same view HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]Waqar[/eluser] Yeah sorry about the mistake i want to insert and update in the same view HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]umefarooq[/eluser] Hello waqar your add and edit are two different function of your controller, if you are using form helper for your form development in add function leave blank value section, while in edit function put your fatched records value add function Code: $data['title'] = array('name'=>'name','id'=>'name'); edit function Code: $row = fetch record from model; and your view Code: <?=form_input($title)?> try this it will work HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]n0xie[/eluser] [quote author="pistolPete" date="1239129694"]Insert and update in the same view[/quote] Click there. You will find http://codeigniter.com/wiki/Add_Edit_Views/ HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]Waqar[/eluser] Here is my controler Code: function add_edit() model Code: function add_individual() Code: $attributes = array('class' => 'indvidual', 'id' => 'individualform'); HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]Waqar[/eluser] I am not understanding how to use the values in the form field if id is present coz it is giving me severity error. HI guys how can i use same form for edit and add data into database? - El Forum - 04-07-2009 [eluser]umefarooq[/eluser] hi nothing is difficult now u have to modify little things in code and in you database table there should be one field name id or what ever you like as a key to update your record and it can be your auto increment key in your table also add function Code: $data['title'] = array('name'=>'name','id'=>'name'); edit function Code: $row = fetch record from model; and your view Code: <?=form_input($title)?> HI guys how can i use same form for edit and add data into database? - El Forum - 04-08-2009 [eluser]Waqar[/eluser] I am having problem loading the view form with values. it will load the edit form but when i click on add it will give me severity error and undefined row Quote:<?php help would be appreciated; HI guys how can i use same form for edit and add data into database? - El Forum - 04-08-2009 [eluser]umefarooq[/eluser] hi you are no following the MVC pattern that's why you are getting this error your code should be in you controller, that' you are getting error here is your code will be like this Model Code: function get_record($id){ controller Code: if($this->uri->segment(3)){ View Code: <input type=“hidden” name=“id” value=”<?=$row->id?>” > you code will be clean |