![]() |
Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - 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: Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin (/showthread.php?tid=6491) |
Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 06-29-2008 [eluser]vadivelan[/eluser] Welcome Thomas! Best Wishes Velan Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-14-2008 [eluser]Dan Murfitt[/eluser] Thanks for posting this. I've found that the default value works well, the only problem I'm having now is with the error message. If you set the rule for the (say) multiple checkbox field to 'required' then the default error message needs changing. So, I did this with: Code: $this->validation->set_message('required', 'Please check %s'); This can then be adapted by entering the information in the fields array. However, this seems to change the message for all other fields apart from the checkboxes. I then tried setting a callback to validate checkboxes instead of using the 'required' rule (so I could set the error message from within the callback function), however, the callback function only seems to run when at least one of the checkboxes is checked. Does anyone have a work around for this? Many thanks Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-15-2008 [eluser]Dan Murfitt[/eluser] Looking closer, the error message returned for the checkbox array with the 'required' rule was coming from $lang['isset'] rather than $lang['required'] (which the other fields with 'required' were) (see http://codeigniter.com/wiki/Validation/). This means that to change the error message for the checkbox array with the validation fix and 'required' rule you need to use something like: Code: $this->validation->set_message('isset', 'Please select at least one %s'); Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-18-2008 [eluser]The Wizard[/eluser] Hello Friends, how does it look like when we generate dropdowns with the form helper? are we able to add validation to them? Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-20-2008 [eluser]drewbee[/eluser] I personally vote this going in as a bug. I find (at least myself) every 2 to 3 forms i build out of say 5, require the use of an array data being passed. I was really surprised this wasn't standard functionality. Thanks for the extension. I look forward to this being standard functionality ![]() This also works with the 'set default values' hack that has been going around for CI's Validation library. I know, it probably doesn't belong there. I just couldn't justify a hole new helper just for one function. Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-21-2008 [eluser]The Wizard[/eluser] yeah i think it should be standart behavior too ![]() Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-26-2008 [eluser]Derek Jones[/eluser] Hey gang, there have been some significant changes to the validation library I thought everyone here would be interested in. Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-26-2008 [eluser]The Wizard[/eluser] thank god ![]() yeah, ill look at it Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 08-26-2008 [eluser]drewbee[/eluser] Chamone!!! ::goes and grabs a full jar of cookies:: Validation of listbox, checkbox groups and reselect multiple values using set_select, set_checkbox / Sol: Array to strin - El Forum - 09-25-2008 [eluser]kamal1976[/eluser] Hello, I made those changes in the validation class but still I am getting following notices for Check Box and List Box with multiple values selected. A PHP Error was encountered Severity: Notice Message: Undefined index: cash_codes Filename: libraries/MY_Input.php Line Number: 132 My Smarty template code for the check box is <input type="checkbox" name="cash_codes" id="cash_codes" <!--[if $CASH_CODES_ONLY == "on" ]-->checked<!--[/if]-->>Cash Codes Only //This is my second check box <input type="checkbox" name="summary_flag" id="summary_flag">Summary</td> Both the check boxes are single and independent. My code for the list box with multiple selection is as given below. <select name="txn_code_list[]" id="txn_code_list" value="" multiple="multiple" size="15" style="width:200px"> <!--[foreach item=RESULT from=$RESULTS]--> <option value="<!--[$RESULT.transaction_code]-->"><!--[$RESULT.transaction_code]--> <!--[$RESULT.description]--></option> <!--[/foreach]--> </select> It gives following notice. A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: libraries/MY_Validation.php Line Number: 552 This is my code in controller $product_code = $this->input->post('product_code'); $summary_flag = $this->input->post('summary_flag'); $user_id_list = $this->input->post('user_id_list'); Can you please guide me how to solve this errors with out suppressing them. Thank you... |