Hey,
First it was all working fine... But suddenly, my backend app's select
stopped working as expected.
It's a common city/neighborhood select. When u change the city, it
shows the neighborhoods in that city.
Problem is: Okey, I change the city and it changes the neighborhoods.
So I select a neighborhood. Perfect. BUT, when I submit the form,
sfValidator shows an error in that field, saying it's required.
Why? Because it simply ignores all the options that were there (and
the option that I did select, among all others), and just select and
shows the first option, which is an empty option inserted via my form
class:
$this->widgetSchema['neighborhood']->addOption('add_empty','Select a
city');
The way I'm doing is:
If no JS is enabled, then all the neighborhoods are going to be
displayed in that field. Otherwise, all select options are erased from
that field and just when the city's select is changed that via AJAX
the neighborhood is going be populated.
This is my jquery/javascript part:
$(document).ready(function()
{
$("#desc_register_neighborhood").removeOption(/./);
$("#desc_register_neighborhood").attr("disabled","disabled");
$('#desc_register_city').change(function()
{
if ($(this).val())
{
$.getJSON(
$(this).parents('form').attr('action') + '/city',
{ query: this.value },
function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '<option value="' + j[i].optionValue + '">' + j
[i].optionValue + '</option>';
}
$("#desc_register_neighborhood").html(options);
$("#desc_register_neighborhood").attr("disabled",false);
$("#desc_register_neighborhood").removeAttr('disabled');
}
);
}
else
{
$("#desc_register_neighborhood").removeOption(/./);
$("#desc_register_neighborhood").addOption('','Selecione uma
cidade');
$("#desc_register_neighborhood").attr("disabled","disabled");
}
}
);
});
Any ideas over this?
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---