php - Symfony2 nothing happens when I display my form inside a class -


so following documentation , making form inside own class:

<?php namespace mp\shopbundle\form\type;  use symfony\component\form\abstracttype; use symfony\component\form\formbuilder; use symfony\component\form\formbuilderinterface; use symfony\component\form\formview; use symfony\component\form\forminterface; use symfony\component\optionsresolver\options; use symfony\component\optionsresolver\optionsresolverinterface; use symfony\component\propertyaccess\propertyaccess;   class registerformtype extends abstracttype {     public function registerform(formbuilderinterface $builder, array $options) {                  $builder                                 >add('title', 'choice', array(                 'choices' => array('-' => '-', 'mr' => 'mr.', 'mrs' => 'mrs.', 'mss' => 'miss.'),                 'label' => 'title * ',                 'attr' => array('class' => 'span1')))                 ->add('firstname', 'text', array(                 'label' => 'first name * ',                 'attr' => array('placeholder' => 'first name')))                 ->add('lastname', 'text', array(                 'label' => 'last name * ',                 'attr' => array('placeholder' => 'last name')))                 ->add('email', 'email', array(                 'label' => 'email * ',                 'attr' => array('placeholder' => 'email')))                 ->add('password', 'password', array(                 'label' => 'password * ',                 'attr' => array('placeholder' => 'password')))                 ->add('dateofbirth', 'date', array(                 'label' => 'date of birth * ',                 'widget' => 'choice'))                 ->add('company', 'text', array(                 'label' => 'company ',                 'attr' => array('placeholder' => 'company')))                 ->add('adress', 'text', array(                 'label' => 'adress * ',                 'attr' => array('placeholder' => 'adress')))                 ->add('country', 'country', array(                 'label' => 'country * ',                 'attr' => array('placeholder' => 'country')))                 ->add('state', 'text', array(                 'label' => 'state * ',                 'attr' => array('placeholder' => 'state')))                 ->add('city', 'text', array(                 'label' => 'city * ',                 'attr' => array('placeholder' => 'city')))                 ->add('zippostalcode', 'text', array(                 'label' => 'zip / postal code *',                 'attr' => array('placeholder' => 'zip / postal code')))                 ->add('additionalinformation', 'textarea', array(                 'label' => 'additional information ',                 'attr' => array('placeholder' => 'additional information')))                 ->add('homephone', 'number', array(                 'label' => 'home phone ',                 'attr' => array('placeholder' => 'home phone')))                 ->add('mobilephone', 'number', array(                 'label' => 'mobile phone ',                 'attr' => array('placeholder' => 'mobile phone')))                 ->add('save', 'submit', array('label' => 'register'));       } public function getname()     {         return 'register_form_users';     } } 

it looks simple form. in controller want show it:

use mp\shopbundle\form\type\registerformtype;  public function registeraction()     {                $em = $this->getdoctrine()->getmanager();             $products = $em->getrepository('mpshopbundle:product')->findall();              $form = $this->createform(new registerformtype());                 return $this->render('mpshopbundle:frontend:registration.html.twig',  array(                'products'=>$products,                'form'=>$form->createview(),                    ));         } 

my twig:

<h3>your personal information</h3> {{ dump(form) }} {% form_theme form _self %}  {{ form(form) }} 

the thing im not getting form. page , template loads fine, not form.

when {{ dump(form) }} something:

formview {#2110 ▼   +vars: array:33 [▶]   +parent: null   +children: array:1 [▶]   -rendered: true } 

as can see getting form? not displaying?... why that?

you must change method

public function registerform(formbuilderinterface $builder, array $options) { 

to

public function buildform(formbuilderinterface $builder, array $options) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -