This topic contains 3 replies, has 3 voices, and was last updated by Alexandr Smaga 9 years, 8 months ago.
-
Topic
-
Hi everyone,
am trying to create a bundle which contains 2 Entities Product, and Brand
in Product Entity I have ManyToOne property with the brand entity
my issue is when I’m creating new product I need to select brand from the brand entity ,but the brand field is allows showing searching and not returning any results back, I’m not sure what I’m missing but here is some of what I did so Far
I have selected parts of the code which is relevantForm->Type->BrandSelectType Class
123456789101112131415161718192021222324252627282930313233343536373839namespace Faumix\ProductBundle\Form\Type;use Symfony\Component\Form\AbstractType;use Symfony\Component\OptionsResolver\OptionsResolverInterface;class BrandSelectType extends AbstractType {const NAME = 'fmx_brand_select';/*** {@inheritdoc}*/public function setDefaultOptions(OptionsResolverInterface $resolver){$resolver->setDefaults(array('configs' => array('placeholder' => 'fmx.product.form.choose_brand'),'autocomplete_alias' => 'brands'));}/*** {@inheritdoc}*/public function getParent(){return 'oro_jqueryselect2_hidden';}/*** {@inheritdoc}*/public function getName(){return self::NAME;}}Resources->config->from.yml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566parameters:fmx.brand.form.type.class: Faumix\ProductBundle\Form\Type\BrandTypefmx.brand.entity.class: Faumix\ProductBundle\Entity\Brandfmx.brand.form.type.api.class: Faumix\ProductBundle\Form\Type\BrandApiTypefmx.brand.form.handler.class: Faumix\ProductBundle\Form\Handler\BrandHandlerfmx.form.type.brand_select.calss: Faumix\ProductBundle\Form\Type\BrandSelectTypeservices:fmx.brand.form.type:class: %fmx.brand.form.type.class%tags:- { name: form.type, alias: fmx_brand }fmx.brand.form.type.api:class: %fmx.brand.form.type.api.class%tags:- { name: form.type, alias: fmx_brand_api }fmx.brand.form:class: Symfony\Component\Form\Formfactory_method: createNamedfactory_service: form.factoryarguments:- "fmx_brand_form"- "fmx_brand"fmx.brand.form.api:class: Symfony\Component\Form\Formfactory_method: createNamedfactory_service: form.factoryarguments:- "brand"- "fmx_brand_api"fmx.brand.form.handler:class: %fmx.brand.form.handler.class%scope: requestarguments:- @fmx.brand.form- @request- @doctrine.orm.entity_managerfmx.brand.form.handler.api:class: %fmx.brand.form.handler.class%scope: requestarguments:- @fmx.brand.form.api- @request- @doctrine.orm.entity_managerfmx.brand.form.type.brand_select:class: %fmx.brand.form.type.brand_select.calss%arguments:- @doctrine.orm.entity_managertags:- { name: form.type, alias: fmx_brand_select }fmx.brand.form.autocomplete.brand.search_handler:parent: oro_form.autocomplete.search_handlerarguments:- %fmx.brand.entity.class%- ["name"]tags:- { name: oro_form.autocomplete.search_handler, alias: brands, acl_resource: fmx_brand_view }Form->ProductType
12345678910111213141516171819202122232425262728293031class ProductType extends AbstractType {const NAME = 'fmx_product';/*** {@inheritdoc}*/public function buildForm(FormBuilderInterface $builder, array $options){$builder->add('name','text',array('required' => true, 'label' => 'fmx.product.product.name.label'))->add('description','textarea',array('required' => false, 'label' => 'fmx.product.product.description.label'))->add('brand','fmx_brand_select',array('label' => 'Product Brand','required' => True,)) ;}cheers
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.