php - Can't access to attributes of a custom form type -
i created tow custom childs of forms type 'informationstype' , 'teamstype' related form 'trainingstype' via embed form:
trainingstype:
use appbundle\form\informationstype; use appbundle\form\teamstype; class trainingstype extends abstracttype { public function buildform(formbuilderinterface $builder, array $options) { $builder ->add('team', teamstype::class) ->add('information', informationstype::class); } teamstype:
class teamstype extends abstracttype { public function buildform(formbuilderinterface $builder, array $options) { $builder->add('nameinstitue')->add('namespace')->add('webspace') ->add('members', collectiontype::class, [ 'entry_type' => team_memberstype::class, 'allow_delete' => true, 'allow_add' => true, 'by_reference' => false, ]); } informationstype:
class informationstype extends abstracttype { /** * {@inheritdoc} */ public function buildform(formbuilderinterface $builder, array $options) { $builder->add('category', choicetype::class, array( 'choices' => array( 'formation' => 'francais', 'certification' => 'certification', 'tutoriel' => 'tutoriel', 'conférence' => 'conférence', 'atelier' => 'atelier', 'webinar' => 'webinar', 'meet-up' => 'meet-up', ), ))->add('language', choicetype::class, array( 'choices' => array( 'francais' => 'francais', 'anglais' => 'anglais', ), ))->add('eventtype', choicetype::class, array( 'choices' => array( 'permanant' => 'permanant', 'session' => 'session', ), ))->add('pricedescription')->add('title')->add('webadress')->add('description')->add('priceradio')->add('validationtype') ->add('trainingprice',choicetype::class, array( 'choices' => array('gratuit'=>'gratuit','payant'=>'payant','abonnement'=>'abonnement'),'multiple'=>false,'expanded'=>true)) ->add('ischeckedpiece', checkboxtype::class, array( 'required' => false, )); } when render trainings form via {{form(form)}} every thing works . in case need loop form.team.members, because it's collections type form add , delete options, here
the problém can't access team attribute ({{form(form.team)}}, doesnt exist !!
i tried dump(form) , formview object without team attribute it's wired, because got form when rendred via {{form(form)}}:
formview {#365 ▼ +vars: array:24 [▼ "value" => informations {#313 ▶} "attr" => [] "form" => formview {#365} "id" => "appbundle_informations" "name" => "appbundle_informations" "full_name" => "appbundle_informations" "disabled" => false "label" => null "label_format" => null "multipart" => false "block_prefixes" => array:3 [▶] "unique_block_prefix" => "_appbundle_informations" "translation_domain" => null "cache_key" => "_appbundle_informations_appbundle_informations" "errors" => formerroriterator {#555 ▶} "valid" => true "data" => informations {#313 ▶} "required" => true "size" => null "label_attr" => [] "compound" => true "method" => "post" "action" => "" "submitted" => false ] +parent: null +children: array:12 [▼ "category" => formview {#610 ▶} "language" => formview {#641 ▶} "eventtype" => formview {#659 ▶} "pricedescription" => formview {#668 ▶} "title" => formview {#670 ▶} "webadress" => formview {#672 ▶} "description" => formview {#674 ▶} "priceradio" => formview {#676 ▶} "validationtype" => formview {#678 ▶} "trainingprice" => formview {#680 ▶} "ischeckedpiece" => formview {#682 ▶} "_token" => formview {#696 ▶} ] -rendered: false -methodrendered: false } any help, explanation !!
i think want use
attribute(form, team) see https://twig.symfony.com/doc/2.x/functions/attribute.html
edit:
your dump looks dump of informationstype , not trainingstype, sure you're using right form?
Comments
Post a Comment