I just don't get it, I tell ya!! |
[eluser]cobolCowboy[/eluser]
I created an MVC setup that works great! Shows a form, POSTs the values then takes the data and inserts it to the database. Now, I want to use the same form view to display the row for update purposes. So I created an update function in the controller that successfully retrieves an array with the row in it based on $id, but I fail to understand how to pass that data to the view so that the values are pre-populated on the form. The form view in embedded using a load into my template view by way of a content identifier that I pass to the template view. The view looks like this: Code: <?php echo form_open('advertisers/$action'); ?> them above view back loads the form when posting error messages. So I created this the model function... Code: function getAdvsWhere($field,$param) The controller does this... Code: function Advertiser_Update($id)
[eluser]Jelmer[/eluser]
Take another look at the set_value() function in the User Guide (http://ellislab.com/codeigniter/user-gui...elper.html). The set_value() function only returns a value when that value is in the POST vars or a default has been set, not when a similar named variable is passed to the View. Since you're already passing them to the view as variables you only have to pass them to the set_value() function as the second parameter, which is the default value. For example, this one: Code: <?php echo set_value('public_link'); ?> Code: <?php echo set_value('public_link', $public_link); ?> And one additional suggestion: in the controller you expect only 1 value in return with: Code: $row = $this->advs->getAdvsWhere('id', $id);
[eluser]cobolCowboy[/eluser]
Thank you Jelmer! I greatly appreciate your help, and it helped a great deal. I have unfortunately not been able to get the set_value() function to populate the TEXTAREA in my form. It work for all INPUT TYPE="TEXT" fields but not for the TEXTAREA field. Any clues on where I can fix this in the core logic, if indeed it needs fixing?
[eluser]Jelmer[/eluser]
That's easily explained if your textarea still looks the same: Code: <textarea name="desc_txt" value="<?php echo set_value('desc_txt'); ?>" rows="10" cols="100"</textarea> That should be: Code: <textarea name="desc_txt" rows="10" cols="100"><?php echo set_value('desc_txt', $desc_txt); ?></textarea>
[eluser]cobolCowboy[/eluser]
I can't help feeling like a fool!! I should not be taking up your time with HTML syntax. Thank again, and have a Happy New Year!
[eluser]Kip zonder Kop[/eluser]
[quote author="cobolCowboy" date="1262239334"]I can't help feeling like a fool!! I should not be taking up your time with HTML syntax. Thank again, and have a Happy New Year![/quote] You're doing pretty well for a mainframe guy. I appreciate your enthusiasm. In a couple of weeks you'll be answering my questions. Cheers |
Welcome Guest, Not a member yet? Register Sign In |