Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony 1.4 form with two models binding issue
    primarykey
    data
    text
    <p>I'm working on a form with Symfony 1.4.<br> It is based on one model but also another model.<br> The form works, but I can't retrieve POST data when binding. </p> <p>Here are the models :</p> <pre><code>ModelA id text something_else_id </code></pre> <p>.</p> <pre><code>ModelB id name modele_a_id </code></pre> <p>And here is how the form looks like :</p> <pre><code>[] modele_b_entry_name_1 [] modele_b_entry_name_2 [] modele_b_entry_name_3 text [_______________________________] [ Submit ] </code></pre> <p>I tried to do a <code>var_dump($request-&gt;getParameter('model_a_form'))</code> and this is what I got :</p> <pre><code>array (size=5) 'id' =&gt; string '20' (length=2) 'modele_b_entry_name233' =&gt; string '233' (length=3) 'modele_b_entry_name236' =&gt; string '236' (length=3) 'text' =&gt; string 'hello world' (length=11) </code></pre> <p>The values are correct.<br> Thought, the binding doesn't work at all.<br> When I do that :</p> <pre><code>$form = new ModelAForm(); $form-&gt;bind($request-&gt;getParameter('model_a_form')); var_dump($form); </code></pre> <p>I get the form with an array of null data.<br> Of course the validation doesn't work, when I try a <code>$form-&gt;renderGlobalErrors()</code>, I get the following message : <code>Unexpected extra form field</code>. </p> <p>Now I'm thinking of using the POST data directly, without using the binding and validation, except if there is a way to correct that.</p> <p>Thank you for your help !</p> <p>Edit :</p> <pre><code>public function configure() { unset($this['created_at'], $this['something_else_id']); $model_a_id = $this-&gt;getObject()-&gt;getId(); $tabModelB = ...; // Query to get all the ModelB in array. $this-&gt;generateCheckboxList($tabModelB); // Method which add the checkboxes to the widget schema. $this-&gt;getWidgetSchema()-&gt;moveField('text', sfWidgetFormSchema::LAST); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload