symfony 2 cascade dropdownlist null
I have a class ArbolCatalogoAdmin which extends Admin with this function
in it:
protected function configureFormFields(FormMapper $formMapper) {
$formMapper
->add('idarbol', null, array('label' =>
$this->getTranslator()->trans('idarbol')))
->add('grado', null, array('label' =>
$this->getTranslator()->trans('grado')))
->add('tablaCatalogo', 'choice', array('label' =>
$this->getTranslator()->trans('tablacatalogo'),
'required' => true,
'choices' => $this->getConfigurationPool()->getContainer()
->get('doctrine')->getManager()->getRepository('TESBundle:ArbolCatalogo')
->getCatalogos()))
->add('tablaCatalogoCampo', 'choice', array('label' =>
$this->getTranslator()->trans('tablacatalogocampo'),
'required' => true,
));
}
in standard_layout.html.twig I fill the secondary dropdownlist like this:
$('select[id$=_tablaCatalogo]').change(function() {
var url = Routing.generate('catalogo_getcampos', { nombreTabla:
$('select[id*=_tablaCatalogo]').val() });
//alert(url);
$.getJSON(
Routing.generate('catalogo_getcampos', { nombreTabla:
$('select[id*=_tablaCatalogo]').val() }),
function(resp) {
var html_options_combo2 ='';
for (var j = 0; j < resp.datos.length; j++) {
html_options_combo2 += "<OPTION
VALUE='"+resp.datos[j].tablaCatalogoCampo+"'>"+resp.datos[j].tablaCatalogoCampo+"</OPTION>";
}
$('select[id*=_tablaCatalogoCampo]').html(html_options_combo2);
});
});
It works fine, but when i click save, the secondary dropdownlist is always
null, and I get error: "This value is not valid".
What am I missing? Thanks in advance
No comments:
Post a Comment