set_value() and callbacks - 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: set_value() and callbacks (/showthread.php?tid=33890) |
set_value() and callbacks - El Forum - 09-11-2010 [eluser]Unknown[/eluser] hi! why is is that every time i use callbacks, the form does not echo the input value enymore? please help. thanks! CONTROLLER: Code: $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[6]|callback__validate_username'); Code: echo '<tr><th>Username<span class="req">*</span></th><td>'.form_input('username', set_value('username')).'</td><td>'.form_error('username','<div class="error">','</div>').'</td></tr>'; Code: function checkUsername() set_value() and callbacks - El Forum - 09-12-2010 [eluser]Pascal Kriete[/eluser] Callbacks can return one of two things: - A boolean (TRUE / FALSE) to indicate a passed or failed rule. - A string that will be used as the new value. Trim, for example, does this. We check the type of the return value (is_bool()), so in your example you need to explicitly return FALSE if it fails. Code: return ($query->num_rows == 1) ? TRUE : FALSE; set_value() and callbacks - El Forum - 09-13-2010 [eluser]Unknown[/eluser] got it! thank you so much. |