Note that there are some explanatory texts on larger screens.

plurals
  1. POEmbeddedForm symfony saving
    primarykey
    data
    text
    <p>I'm experiencing a problem to solve the newly added "Prix" in my Soiree Form</p> <p>I've embedded the PRixForm in my SoireeForm and i'm using ajax calls to add as many prix as we want.</p> <p>The problem is, when I want to add a new PRix by clicking on the "+" and after filling my fields nothing is saved... When i'm editing or filling the first default embedded form prix it works which is weird. Only those added by ajax are not saved..</p> <p>Here is my code</p> <p>in my form, SoireeForm:</p> <pre><code>public function addNewPrix($number){ $new_prix = new BaseForm(); for($i=0; $i &lt;= $number; $i+=1){ $pri = new Prix(); $pri-&gt;setSoiree($this-&gt;getObject()); $prix_form = new PrixForm($pri); $new_prix -&gt;embedForm($i, $prix_form); } $this-&gt;embedForm('new', $new_prix); } public function saveEmbeddedForm($con = null, $forms = null){ $dataForms = $this-&gt;getEmbeddedForm('new')-&gt;getEmbeddedForms(); foreach ($dataForms as $dataForm) $dataForm-&gt;getObject()-&gt;setSoiree($this-&gt;getObject()); parent::saveEmbeddedForm($con, $forms); } </code></pre> <p>In my action:</p> <pre><code>public function executeAdd($request) { $this-&gt;forward404unless($request-&gt;isXmlHttpRequest()); $number = intval($request-&gt;getParameter("num")); $this-&gt;form = new SoireeForm(); $this-&gt;form-&gt;addNewPrix($number); return $this-&gt;renderPartial('addPri',array('form' =&gt; $this-&gt;form, 'num' =&gt; $number)); } </code></pre> <p>my partial addPri:</p> <pre><code>&lt;li&gt; &lt;?php echo $form['new'][$num]['titre']-&gt;renderLabel();?&gt; &lt;?php echo $form['new'][$num]['titre']-&gt;render()?&gt; &lt;?php echo $form['new'][$num]['montant']-&gt;renderLabel();?&gt; &lt;?php echo $form['new'][$num]['montant']-&gt;render();?&gt; &lt;br /&gt; &lt;br /&gt; </code></pre> <p></li></p> <p>and my prix.js file:</p> <pre><code>newfieldscount = 0; function addPri(num) { return $.ajax({ type: 'GET', url: '/backend_dev.php/soiree/add?num='+num, async: false }).responseText; }; var removeNew = function(){ $('.removenew').click(function(e){ e.preventDefault(); $(this).parent().remove(); }) }; $(document).ready(function(){ $('#add_prix').click(function(e) { e.preventDefault(); $("ul#extraprix").append(addPri(newfieldscount)); newfieldscount = newfieldscount + 1; $('.removenew').unbind('click'); removeNew(); }); </code></pre> <p>});</p> <p>I guess the problem comes from my saveEmbed method in my form, but i don't understand why or how to make everything work as it should.</p> <p>Thank you in advance you guys</p>
    singulars
    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.
 

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