Good morning,
In Symfony 1.4, I have two models, as in the following example :
ModelA
id
text
.
ModelB
id
name
modele_a_id
I want to create a form with checkboxes for each ModeleB entries, and a textarea for the text of ModeleA, like that :
[] modele_b_entry_name_1
[] modele_b_entry_name_2
[] modele_b_entry_name_3
text
[_______________________________]
I'm not sure of how to do that.
For the moment I have modified the ModeleAForm which was generated.
Here is the Form code :
$a_id = $this->getObject()->getId();
$query = Doctrine_Query::create()
->from('ModeleB m')
->where('m.modele_a_id = ?', $a_id);
$all_modele_b_entries = $query->execute();
$this->widgetSchema['all_modele_b_entries'] = new sfWidgetFormSelectCheckbox(array('choices' => $all_modele_b_entries));
And the template is very simple, it just shows the form.
I'm getting what I want, except that the labels of the checkboxes are the id of modele_b.
I'm wondering if I should use sfWidgetFormInputCheckbox instead of sfWidgetFormSelectCheckbox and then loop on it.
What do you think of this ? What is the best way to do it for you ?
Thank you in advance for your advices.
Edit :
Trying with the suggestion :
$this->widgetSchema['all_modele_b_entries'] = new sfWidgetFormDoctrineChoice(array(
'model' => 'ModeleB',
'expanded' => true,
'multiple' => true,
'query' => $query ));