![]() |
Multiple is_unique and set_message - 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: Multiple is_unique and set_message (/showthread.php?tid=49972) |
Multiple is_unique and set_message - El Forum - 03-09-2012 [eluser]Noobigniter[/eluser] Hi, I try for a while, despite the documentation, to define a message for each is_unique, but without success. Everything works well with one set_message. If I add one, it overrides the previous one, so I tried this: Code: $this->form_validation->set_rules(' ... |is_unique[menu.page]|xss_clean'); Code: Unable to access an error message corresponding to your field name. How to proceed to have several different messages ? It is necessary to use personal callback_ ? In advance, thank you. Multiple is_unique and set_message - El Forum - 03-09-2012 [eluser]porquero[/eluser] I think that you should try set message without table.field: Code: $this->form_validation->set_rules(' ... |is_unique[menu.page]|xss_clean'); Multiple is_unique and set_message - El Forum - 03-09-2012 [eluser]Noobigniter[/eluser] Yes, for a field it works fine, but I want different message for each, like this example: Code: $this->form_validation->set_rules('page', 'Page', '... |is_unique|xss_clean'); I thought it was possible to do directly, but if this is not the case, I would call the callback Multiple is_unique and set_message - El Forum - 03-09-2012 [eluser]CroNiX[/eluser] Unfortunately the error message is set by the rule name and not the individual field. I've seen some code in the wiki that let's you set it by the individual field, but haven't tried it. You can always copy the is_unique() method into a MY_Form_validation extension and rename it to something else and set a new custom error message as a workaround. Not the most efficient and violates DRY principles, but it works. Multiple is_unique and set_message - El Forum - 03-09-2012 [eluser]Noobigniter[/eluser] Ok, thank you for the clarification. I'll go see it, and at worst I will use the callback. ![]() Multiple is_unique and set_message - El Forum - 09-23-2013 [eluser]bretticus[/eluser] Grrr. Super lame! Means I have to create a callback that calls unique in order to use it multiple times per form submission and have multiple custom error messages. |