![]() |
Brainstew over form population - 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: Brainstew over form population (/showthread.php?tid=24911) |
Brainstew over form population - El Forum - 11-24-2009 [eluser]CodeTroll[/eluser] My goal is to use the same view/template for editing and creating a blog entry. I started out with form validation as per the documentation and that works fine when submitting the form. My next step was to prepopulate the form with data from the database. As can be seen from the 'blog_entry' => $this->blog_model->get_entry($blogid) the result array is one level lower than the other fields in $data. I guess that is the problem, but I am not sure how to fix it.. I could get each field from the database array and add it manually to the $data array, but if an easier way exists I would appreciate it ![]() Relevant database fields: Code: blogid Sorry some of the text is in danish - but it should be understandable anyway (rediger=edit) Snippet from controller: Code: function rediger($blogid) { Snippets from view/template blog_rediger.php Code: <?php echo validation_errors(); ?> Brainstew over form population - El Forum - 11-24-2009 [eluser]jedd[/eluser] I think, but am not completely sure, that you may just be looking for a reminder that the set_value() function takes two parameters. Brainstew over form population - El Forum - 11-24-2009 [eluser]CodeTroll[/eluser] Hmm I already tried that - it may just be my lack of array handling in PHP that fries my brain. blog_entry is the key and then I have the row as the value - but can I dig that out in a oneliner or have I missed something? (still sifting through the Bamboo application to get some ideas before I get too far in my own code ramblings ![]() Brainstew over form population - El Forum - 11-24-2009 [eluser]Flemming[/eluser] if in doubt with arrays, just use your old friend print_r($array) in your view (in your case, print_r($blog_entry) - this will give you a clue how to extract the data that is contained in $blog_entry Brainstew over form population - El Forum - 11-24-2009 [eluser]CodeTroll[/eluser] Problem is solved.. well - sorta.. I changed from $this->Parser-parse('blog_edit',$data) to $this->load->view('blog_edit',$data) and my data came out... so it seems there is a difference as how $data is available in views and in templates.. Hmmmm |