[eluser]Unknown[/eluser]
Hey Guys,
I have a question for you. I have a form where some fields require validation, and some do not. Since I only have some fields that need to be validated, I only have those ones in my validation rules:
Code:
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
$this->form_validation->set_rules('message', 'Message', 'required');
There are two additional fields that are in the form, which are "company" and "website". I was using "set_value()" to return the value's to my fields in my view file, but for my "company" and "website" fields, they were not showing their value - obviously because I am not declaring them in my validation rules (because they don't need to be validated). What I am doing instead is using the post array through the input class to return values to all my fields.
My question is this: what is the best way to handle forms where I have required and non required fields. Should I add the non required fields into the form validation class, and just specify no rules so I can use the "set_value()" function, or should I set the values for all form fields in the view using the post array.
Thanks,
~Nicholas