Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to handle Symfony form collection with 500+ items
    primarykey
    data
    text
    <p>I have form collection which need to handle more than 500 entity instances. After I increased timeout to 60s and increased max_input_vars form work but it is annoying how slow it is. Rendering form is slow but submitting that big form is pain in the ass.</p> <p>I was considering creating plain HTML form but there is some other drawback suck as validation. So, is there any proper way to handle that big set of data via symfony form ?</p> <p>CONTROLLER:</p> <pre><code>public function ratesCardAction() { $bannerList = $this-&gt;data; $em = $this-&gt;getDoctrine()-&gt;getManager(); $form = $this-&gt;createForm(new AdvertiserRatesType($bannerList)); if ('POST' == $this-&gt;getRequest()-&gt;getMethod()) { $form-&gt;handleRequest($this-&gt;getRequest()); $advertiserCampaign = $form-&gt;getData(); if ($form-&gt;isValid()) { foreach ($advertiserCampaign['campaignsAdZones'] as $campaignAdZone) { $em-&gt;persist($campaignAdZone); } $em-&gt;flush(); } } return array( 'form' =&gt; $form-&gt;createView() ); } class AdvertiserRatesType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder -&gt;add('campaignsAdZones', 'collection', array( 'type' =&gt; new AdvertiserRatePerCountryType(), 'data' =&gt; $this-&gt;rates, 'empty_data' =&gt; null, 'options' =&gt; array( 'attr' =&gt; array('class' =&gt; 'campaignAdZoneItem') ) )) ; } } </code></pre> <p>...</p> <p>and embedded form looks like:</p> <pre><code>public function buildForm(FormBuilderInterface $builder, array $options) { $builder-&gt;add('class', 'entity', array( 'class' =&gt; 'AcmeCmsBundle:PublisherTypes', 'property' =&gt; 'class', 'read_only' =&gt; true, 'disabled' =&gt; true ) ) -&gt;add('country', 'entity', array( 'class' =&gt; 'AcmeCmsBundle:Countries', 'property' =&gt; 'name', ) ) -&gt;add('text1') -&gt;add('text2') ; } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver-&gt;setDefaults(array( 'data_class' =&gt; 'Acme\CmsBundle\Entity\Rates' )); } </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.
 

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