![]() |
Combine Edit & Input Views - 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: Combine Edit & Input Views (/showthread.php?tid=5063) |
Combine Edit & Input Views - El Forum - 01-03-2008 [eluser]scottelundgren[/eluser] Is there an elegant way for a view to be used for both data entry of a new record and editing an existing record? I'm trying to add the following logic. If you see a good way to combine these samples of 2 views into 1 view and retain validation I'd appreciate it. Thanks! look up student record if a record is found, load the data from the row into $data, pass $data into the view: Code: <tr> Code: <tr> Combine Edit & Input Views - El Forum - 01-03-2008 [eluser]Pygon[/eluser] you could embed an if statement, such as: Code: <td align="center" valign="middle"> Combine Edit & Input Views - El Forum - 01-03-2008 [eluser]Negligence[/eluser] I set a mode flag (to create or edit) and determine what to show/hide depending on the flag. Same goes for validation. Combine Edit & Input Views - El Forum - 01-03-2008 [eluser]Craig A Rodway[/eluser] This is something I have used since I started with CI and subsequently wrote this article in the wiki. Hope it helps. Combine Edit & Input Views - El Forum - 01-03-2008 [eluser]scottelundgren[/eluser] Ah! That should do it. Thanks! [quote author="Pygon" date="1199397555"]you could embed an if statement, such as: Code: <td align="center" valign="middle"> Combine Edit & Input Views - El Forum - 01-03-2008 [eluser]scottelundgren[/eluser] [quote author="Craig Rodway" date="1199404269"]This is something I have used since I started with CI and subsequently wrote this article in the wiki. Hope it helps.[/quote] That article was helpful. Unfortunately my app is a series of post forms because I have to carry multiple variables so I can't use the uri segment code like the example but I get the gist of the fields function that encapsulates the suggestion of Pygon. |