Re-populating checkboxes -- callback works great, but "selected" doesn't happen |
[eluser]tinawina[/eluser]
I understand that CI doesn't do a good job of checkbox validation out of the box. I got around that by writing a custom callback that does the trick. But what I don't understand is why CI's re-populate checkboxes -- as described in the CI validation class tutorial -- doesn't work. Right now I have a form that is just a little testbed to work this all out. The form has 4 checkboxes. I want to make sure that at least one box is checked, and no more than 3 are checked. Here's my form: Code: <form action="add" method="post"> On the backend, I have this method in my class to handle the submitted form (Note: I am using joeles' callback library and revised validation class): Code: function add() And I have this callback Code: function _boxCheck () When I submit the form with nothing checked, or with all four boxes checked, I get the expected result -- the form is reposted and I see my "Choose at least 1...no more than 3." error message. But when I select all four boxes and submit, I get my error message but none of the previously selected boxes are checked on form re-post. I am hopeful that I've missed something small but crucial (happens to me a LOT). I did see that there's a revised validation class I can use that handles checkboxes efficiently. I was hoping to not mess with the validation class I am using now since it is a custom version and I'd have to merge the two versions (ugh) to get everything working the way I need it to. Thanks for any help offered here! |
Welcome Guest, Not a member yet? Register Sign In |