![]() |
Form input fields +form_validation required but not equal to default??? - 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: Form input fields +form_validation required but not equal to default??? (/showthread.php?tid=26324) |
Form input fields +form_validation required but not equal to default??? - El Forum - 01-11-2010 [eluser]123wesweat[/eluser] Hi, so i am using this to make some form fields Code: <?php echo form_label('fname').form_input('fname','fname');?> and form_validation Code: $this->form_validation->set_rules('fname', 'fname', 'trim|required'); 1/ Now because i already have fname as text value the validation passes, how do i fix this? 2/ How do is set already filled in values?? set_value??? regards, Form input fields +form_validation required but not equal to default??? - El Forum - 01-11-2010 [eluser]123wesweat[/eluser] Is this the way to do it for each input field????? Code: $fname = isset($_REQUEST['fname']) ? $_REQUEST['fname'] : 'fname'; Form input fields +form_validation required but not equal to default??? - El Forum - 01-11-2010 [eluser]danmontgomery[/eluser] Code: <?php echo form_label('fname').form_input('fname',set_value('fname'));?> Form input fields +form_validation required but not equal to default??? - El Forum - 01-11-2010 [eluser]123wesweat[/eluser] @noctrum, thanks But now we don't have a default value to start with?? Let's say "..here your first name" Code: <?php echo form_label('fname').form_input('fname','...here your first name'));?> Code: $fname = isset($_REQUEST['fname']) ? $_REQUEST['fname'] : '...here your first name'; But now i have the validation question. As the validation 'thinks', ...here your first name is your name and it will validate. Any thoughts?? Form input fields +form_validation required but not equal to default??? - El Forum - 01-11-2010 [eluser]jbreitweiser[/eluser] Write a callback that tests for your default value and fails if that value is found. Code: function notDefaultText($str){ Code: $this->form_validation->set_rules('fname', 'fname', 'trim|required|callback_notDefaultText'); |