Mdomba,
Mdomba > If I understood you, when actionDynamicState calls performAjaxValidation you
Mdomba > don’t want the validation to happen for every other action validation should happen.
Correct! That’s exactly what I need.
Here’s the problem:
CustomerController::actionDynamicStates()
is not making an explicit call to the performAjaxValidation() function!
The action which is making that call to performAjaxValidation() is the
CustomerController::actionUpdate() (!)
I know this because I put in some "print to a log file" statements in both action functions.
So now this begs the question: why is actionUpdate() being called when only actionDynamicStates() should be called.
This script is, of course, at the following URL:
index.php/hqadmin/update/id/203
If I click the submit button on that page, I expect actionUpdate() to be called, but I do not expect it to be called when I select a different country from the country dropdown.
If I were to submit the form on that page, I expect actionUpdate() to get called.
But it’s getting called when I select a different country from the country dropdown!
I know we’re on the right track, if I can just figure out why actionUpdate() is being called IN ADDITION to actionDynamicStates(), every time the user selects a different country from the dropdown.
I did a "view source" in my browser to look at the generated Ajax call. I include it below (with newlines added for readability.) This may come down to a jquery issue? Is there some call to say, "do NOT submit the form?"
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('body').delegate(
'#Customer_country_id',
'change',
function(){jQuery.ajax({'type':'POST',
'url':'/index.php/customer/dynamicStates/validate/false',
'dataType':'json',
'complete:function(data) {
$("#div_state").html(data["div_state"]);
$("#div_province").attr("style", data["div_province_style"]);
},
'cache':false,
'data':jQuery(this).parents("form").serialize()});return false;
}
);
$('#customer-form').yiiactiveform(
{'attributes':[{'inputID':'Customer_first_name','errorID':'Customer_first_name_em_','status':1},{'inputID':'Customer_last_name','errorID':'Customer_last_name_em_','status':1},{'inputID':'Customer_login','errorID':'Customer_login_em_','status':1},{'inputID':'Customer_newPassword','errorID':'Customer_newPassword_em_','status':1},{'inputID':'Customer_company','errorID':'Customer_company_em_','status':1},{'inputID':'Customer_address','errorID':'Customer_address_em_','status':1},{'inputID':'Customer_city','errorID':'Customer_city_em_','status':1},{'inputID':'Customer_country_id','errorID':'Customer_country_id_em_','status':1},{'inputID':'Customer_state_id','errorID':'Customer_state_id_em_','status':1},{'inputID':'Customer_province','errorID':'Customer_province_em_','status':1},{'inputID':'Customer_zip_code','errorID':'Customer_zip_code_em_','status':1},{'inputID':'Customer_email','errorID':'Customer_email_em_','status':1},{'inputID':'Customer_phone','errorID':'Customer_phone_em_','status':1},{'inputID':'Customer_status','errorID':'Customer_status_em_','status':1},{'inputID':'Customer_referral_type_id','errorID':'Customer_referral_type_id_em_','status':1},{'inputID':'Customer_referral_notes','errorID':'Customer_referral_notes_em_','status':1},{'inputID':'Customer_is_good','errorID':'Customer_is_good_em_','status':1}],'summaryID':'customer-form_es_'});
});
/*]]>*/
</script>
Thanks again for your help!
Emily