php - Symfony - Multiple Fields for one Entity Attribute -


i have 3 three select fields 1 entity attribute. picture below shows. enter image description here

is there way detect of select fields used; value , map corresponding attribute?

and possible send parameters form type (in example testtype , please see below). trying make generic , re-usable other attributes.

here have now.

myform.php

<?php  namespace mybundle\form;  use mybundle\form\type\testtype; use ..etc  class myform extends abstracttype {      public function buildform(formbuilderinterface $builder, array $options)     {          $builder             ->add('title',      texttype::class)             ->add('d1',         testtype::class);      }      public function configureoptions(optionsresolver $resolver)     {         $resolver->setdefaults(array(             'data_class' => 'mybundle\entity\project'         ));     }       public function getblockprefix()     {         return 'mybundle_project';     }   } 

testtype.php

<?php  namespace mybundle\form\type;  use sonata\adminbundle\form\type\filter\choicetype; use ..etc  class testtype extends abstracttype {     /*      * private $myarray1;      * private $myarray2;      * private $myarray3; numberofseletcs      * private $numberofseletcs;             secondary question: possible send these values parameters?      public function __construct($array1, $array2, $array3, $n)     {         $this->myarray1= $array1;         $this->myarray2= $array2;         $this->myarray3= $array3;         $this->numberofseletcs= $n;      }       */     public function buildform(formbuilderinterface $builder, array $options)     {         $myarray1 = array('label1'=>'','value1'=>'value1', 'value2'=>'value2','value3'=>'value3');         $myarray2 = array('label2'=>'', 'value4'=>'value4','value5'=>'value5');         $myarray3 = array('label3'=>'', 'value6'=>'value6','value6'=>'value6');          $builder             // ...             ->add('h1', 'choice',  array(                 'choices' => $myarray1,                 'choice_attr' => ['label1' => ['disabled selected hidden'=>'']]))             ->add('h2', 'choice',  array(                 'choices' => $myarray2,                 'choice_attr' => ['label2' => ['disabled selected hidden'=>'']]))             ->add('h3', 'choice',  array(                 'choices' => $myarray3,                 'choice_attr' => ['label3' => ['disabled selected hidden'=>'']]));     }   } 

thanks.

to detect of select fields used have use javascript. know symfony php framework working on server-side , detect event on client-side javascript needed. , pass parameter form type have answer in topic


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -