Symfony2 how to get data from a specifique field of an entity to make a form? -
i have entity object size field (which array) different size available. (ex : s, m, xl). not objects have same size available. fill field in form =>
->add('size', 'choice', array('choices' => array('xs' => 'xs', 's' => 's', 'm' => 'm', 'l' => 'l', 'xl' => 'xl'), 'multiple' => true, 'expanded' => true))
so other form user can take available size (for object). type entity not working in case because dont total entity.
i seek
$builder->add('size', 'choice', array( 'class' => 'mywebshopbundle:size', 'property' => 'name', 'expanded' => false, ));
but it's not working if had thought appreciate !
ok create metta info driven creating sort of stock count against sizes relationship relating entity.
then perform query builder in form like
$builder->add('sizes', 'entity', array( 'class' => 'mybundle:sizes', 'query_builder' => function(entityrepository $er) utilize ($thisentity) { homecoming $er->createquerybuilder('s') ->innerjoin('s.clothing', 'c') ->where('c = :entity') ->andwhere('s.stock > :stock') ->setparameters(['entity' => $thisentity, 'stock' => 0]) ->orderby('s.size', 'asc'); }, ));
now there missing bring together should gist
forms symfony2
No comments:
Post a Comment