Form Validation Repopulation with Form Helper |
[eluser]Dan Bowling[/eluser]
I'm having a little trouble finding the proper syntax for repopulating a form after it fails the form_validation class. The example on the User Guide doesn't use the form_helper. How should I repopulate form data with check boxes, drop downs, and radio buttons that use the form_helper? Any generic example would help.
[eluser]xzela[/eluser]
I had a hard time with that issue too. I'm not sure if this is the 'proper' way to do it, but i find this works pretty well. HTML code: Code: <input name='text_box' value='<?php echo set_value('text_box'); ?>' /> Like i said, not sure if that's the proper way to do it. Remember, you'll have to load the 'form' helper to use it. For more details see: http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]xzela[/eluser]
oops, I should have read your post more carefully: sorry... Here's what I do for select fields: Code: <select name='select_id'> Like many things involving code, there is probably a better way. This is just one example of how you could do it.
[eluser]Dan Bowling[/eluser]
Thanks for the suggestion. I've been able to do some similar stuff with my own methods for this, but what I am really looking for is some method that works with the Form Helper. I was able to get the drop down to work alright Code: <?php But I'm stuck with this for checkboxes and radio buttons: Code: <h5>Check Boxes</h5> The difference in elegance is astonishing. I guess it's more a matter of keeping my code clean, and consistent (in regards to using the form helper or not.)
[eluser]phazei[/eluser]
I was thinking about using the form helper with the form validator as I was reading through the user guide just now and wondering about the same question. Has anyone actually integrated the set_XXXX() functions into the form helper form_XXXX() functions? If so, please share! :-) If not, I'll eventually do that myself. Then I'd never have to worry about form population again. ![]() |
Welcome Guest, Not a member yet? Register Sign In |