Welcome Guest, Not a member yet? Register   Sign In
Form Validation Issue with jQuery & Smarty Template Engine
#1

[eluser]Unknown[/eluser]
After submitting my form, this is what I see:

When I print_r($_POST) I see my variable 'shipping_option' and it's value => 'same'.
When I print_r($this->input->post('shipping_option')) I see it's value 'same'.
When I look at my smarty console I see my records for this field:
[shipping_option] =>
[shipping_option_error] => The shipping option field is required.

My rule is: 'shipping_option' => 'required|isset'
My field is: 'shipping_option' => 'shipping option'
I load the following in my controller construct:
$this->load->helper(array('form', 'url'));
$this->load->library('validation');

For the life of me I can't figure out why $this->validation doesn't pick up my 'shipping_option' field. All other fields in my form are fine.
NB: This input-radio button ('shipping_option') has a jQuery.onchange event attached to it which performs an ajax call and retrieves shipping carrier options based on the shipping address provided by the ajax post values.

Any help would be greatly appreciated. Let me know if you need more info. I've been banging my head on this for a few days now...
#2

[eluser]bretticus[/eluser]
Code:
$this->load->library(‘validation’);
is deprecated. Try using
Code:
$this->load->library(‘form_validation’);
Check the manual for details.

If that doesn't help, please post a snippet of your view with the form and the code in your controller or model that handles the form (use code tags please.)
#3

[eluser]Unknown[/eluser]
I found the issue here. There was a loop that changed the value to "" of all post items that start with the prefix "shipping_". The purpose of that is the option of same_as_billing_address where the shipping information items are not needed. Anyway, quite funny scenario. It would ahve been easier to figure this out if the "Shipping_" prefix wasn't store in a constant.

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB