0
votes

Related to this question I'm getting a error while trying to edit any records create previously. This is the error (I omitted some irrelevant pieces for not extend the post so much):

500 | Internal Server Error | Doctrine_Record_UnknownPropertyException Unknown method Estado::

stack trace at () in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php line 2658 ... }

    }

    throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown method

%s::%s', get_class($this), $method));

}


/** at Doctrine_Record->__call('', array()) in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/record/sfDoctrineRecord.class.php

line 197 ... at sfDoctrineRecord->__call('', array()) in n/a line n/a ... at Estado->() in n/a line n/a ... at call_user_func(array(object('Estado'), '')) in SF_ROOT_DIR/plugins/sfDependentSelectPlugin/lib/source/sfDependentSelectObjectSource.class.php line 56 ... at sfDependentSelectObjectSource->getRefValue('15') in SF_ROOT_DIR/plugins/sfDependentSelectPlugin/lib/widget/sfWidgetFormDependentSelect.class.php line 98 ... at sfWidgetFormDependentSelect->render('persona[estado_id]', '15', array(), null) in SF_ROOT_DIR/plugins/sfDependentSelectPlugin/lib/widget/sfWidgetFormObjectDependentSelect.class.php line 70 ... at sfWidgetFormObjectDependentSelect->render('persona[estado_id]', '15', array(), null) in SF_ROOT_DIR/plugins/sfDependentSelectPlugin/lib/widget/sfWidgetFormDoctrineDependentSelect.class.php line 67 ... at sfWidgetFormDoctrineDependentSelect->render('persona[estado_id]', '15', array(), null) in SF_ROOT_DIR/lib/vendor/symfony/lib/widget/sfWidgetFormSchema.class.php line 512 ... at sfWidgetFormSchema->renderField('estado_id', '15', array(), null) in SF_ROOT_DIR/lib/vendor/symfony/lib/form/sfFormField.class.php line 119 ... at sfFormField->render() in SF_ROOT_DIR/lib/vendor/symfony/lib/form/sfFormField.class.php line 58

I don't know where to look for this Estado:: or where it fails, any solution to this?

1
Can you post the definition of the field "estado_id" from the Form class you are using here?Michal Trojanowski
@MichalTrojanowski here $this->widgetSchema['estado_id'] = new sfWidgetFormDoctrineDependentSelect(array( 'model' => 'Estado', 'add_empty' => 'Seleccione estado', 'ajax' => true )); $this->widgetSchema['municipio_id'] = new sfWidgetFormDoctrineDependentSelect(array( 'model' => 'Municipio', 'depends' => 'Estado', 'add_empty' => 'Seleccione municipio', 'ajax' => true, 'order_by' => array('nombre', 'asc') )); also it's in the post refered hereReynier
It looks that you have to specify the 'ref_method' as an option of the Widget. Do you really have to use the sfWidgetFormDoctrineDependentSelect? Maybe you could just use the usual sfWidgetFormDoctrineChoice?Michal Trojanowski
@MichalTrojanowski well I use this because of the dependent select. Is the typical problem of countries > states. What's your suggestion on this? Not to use this plugin and move to just Symfony Core classes? How to get things done with just only Symfony?Reynier
The estado_id doesn't have to be of class sfWidgetFormDoctrineDependentSelect as it does depend on anything. Change the class to sfWidgetFormDoctrineChoice and drop the ajax option and you should be fine.Michal Trojanowski

1 Answers

1
votes

So the problem is with the definition of widgets. The original definition used:

$this->widgetSchema['estado_id'] = new sfWidgetFormDoctrineDependentSelect(array( 
    'model' => 'Estado', 
    'add_empty' => 'Seleccione estado', 
    'ajax' => true 
)); 

$this->widgetSchema['municipio_id'] = new sfWidgetFormDoctrineDependentSelect(array( 
    'model' => 'Municipio', 
    'depends' => 'Estado', 
    'add_empty' => 'Seleccione municipio', 
    'ajax' => true, 
    'order_by' => array('nombre', 'asc') 
));

Both of the widgets are of class sfWidgetFormDoctrineDependentSelect but in fact only municipio_id has dependency.

It seems that sfWidgetFormDoctrineDependentSelect needs either a ref_method or depends options set to work properly.

If you change the estado_id to this it will work:

$this->widgetSchema['estado_id'] = new sfWidgetFormDoctrineChoice(array( 
    'model' => 'Estado', 
    'add_empty' => 'Seleccione estado',
));