tl;dr: is there way have 'context' option auto-cascade through form types ? not leasable pass along manually in form types this:
$builder->add('organizer', 'organizer_type', array('context' => $options['context']));
hello everybody,
i have written extension symfony form types:
class contextextension extends abstracttypeextension { protected $context; public function __construct(securitycontextinterface $context) { $this->context = $context->gettoken()->getuser()->getcontext(); } public function setdefaultoptions(optionsresolverinterface $resolver) { $resolver->setdefaults([ 'context' => $this->context ]); $resolver->setallowedtypes(['context' => 'goc\bundle\frameworkbundle\model\contextinterface']); } /** * returns name of type being extended. * * @return string name of type being extended */ public function getextendedtype() { return 'form'; } }
i have validated registered , working (for part). face 1 problem. when set new option ('context') in form type this:
class eventtype extends abstracttype { public function buildform(formbuilderinterface $builder, array $options) { $builder->add( 'eventgroup', 'eventgroup_type', array( 'context' => $context, ) ) } public function getname() { return 'event'; } }
i receive option in event group form type , can work there:
class eventgrouptype extends abstracttype { public function buildform(formbuilderinterface $builder, array $options) { $this->log($options['context']); $builder ->add('name', 'text') ->add('comment', 'text') ->add('organizer', 'organizer_type') ; } public function getname() { return 'eventgroup_type'; } }
however, appears options not cascade further , therefore not usable in text or organizer type. there way have 'context' option auto-cascade through form types ? not leasable pass along manually in form types this:
$builder->add('organizer', 'organizer_type', array('context' => $options['context']));
Comments
Post a Comment