symfony form builder across a one-to-many to a many-to-one -


i know possible i'm lost on start. main trouble figuring out how set form classes.

entities

formula (id, code, name, formulacolors)

formulacolor (formula, color, percentage)

color (id, code, name, formulacolors)

i want display multiple-choice checklist given formula displays every color in table grid. grid have column displays code, name, , checkbox each color. these not important details though. user should able check boxes , on submit , persist should add check ones formula->formulacolors, adding formulacolor table. also, colors belong formula should checked when form built. think easier me had formulacolor table been true join table without percentage field.

in controller action have access formula needs have colors chosen it.

what form classes like, @ least speaking?

this form class looks far

class choosecolorstype extends abstracttype {     public function buildform(formbuilderinterface $builder, array $options)     {         $builder->add('formulacolors', 'entity', array(                 'class' => 'prismportalcommonbundle:color',                 'property' => 'code',                 'expanded' => true,                 'multiple' => true,             ));     }      public function setdefaultoptions(optionsresolverinterface $resolver)     {         $resolver->setdefaults(array(                 'data_class' => 'prism\portal\commonbundle\entity\formula'             ));     }      public function getname()     {         return 'prism_portal_adminbundle_choosecolorstype';     } } 

however, gives me exception "error: call undefined method prism\portal\commonbundle\entity\color::getpercentage() in /vagrant/src/prism/portal/commonbundle/entity/formula.php line 201"

i'm guessing has being not regular many-to-many relationship. don't know how address getpercentage() exception

update

i haven't gotten chance try yet tomorrow. think may answer problem: http://www.prowebdev.us/2012/07/symfnoy2-many-to-many-relation-with.html

i didn't think of adding a mutator , accessor formula entity dealing color directly.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -