Form Helper: Hidden Input and Validation: Checkbox Arrays |
[eluser]aBoy[/eluser]
Hi. I've been using CI for about three months now. It is excellent, thank you very much. I got some issues so I searched the forum for a while, but still have a couple of questions about the Form Helper class. 1. Is there a way to assign an 'id' to an input_hidden function call? 2. I have a dynamicly generated array of checkboxes which allows the user to select what category their profile/article will exist in. We are only really concerned with the last 6 lines or so; Code: foreach ($sections as $s) { The line; Code: echo form_checkbox( containing the piece of code; Code: $this->validation->set_checkbox('catID[]', $s->sectionID.':'.$s->catID) does not work for an array of checkboxes using the same name. The only time this is an issue is if the user creates a 'new' profile/article and misses one of the other required fields. On return to the form all the fields are re-populated except for the checkboxes. Any ideas?
[eluser]xwero[/eluser]
The form_hidden has no extra parameter i think this has to do with the possibility to add hidden inputs with the form_open tag but it can be fixed. Code: function form_hidden($name, $value = '', $extra = '') Code: $hiddens = array('name1'=>array('value'=>'value1','extra'=>'id="1"'),
[eluser]xwero[/eluser]
I wasn't fully awake For you second question you could use MY_form_helper. It are replacement functions for the CI provided functions that are aware that the form is posted.
[eluser]gkchicago[/eluser]
I was faced with the same problem as your second question regarding checkboxes and didn't like extending the form and validation libraries just to fix it. I have posted my solution to this problem here: http://ellislab.com/forums/viewthread/79792/
[eluser]vadivelan[/eluser]
Hi CI not dealing with user form submitted arrays properly. To deal with that have a look the below thread: http://ellislab.com/forums/viewthread/73012/ |
Welcome Guest, Not a member yet? Register Sign In |