symfonyluxury
6/20/2012 - 12:49 PM

VendorController.php

      public function testAction()
      {

            $em = $this->getDoctrine()->getManager();
            $vendor = $em->getRepository( 'GaorenVendorsBundle:Vendor' )->find( 1);
            $form = $this->createForm( new VendorImageType(), $vendor );

            if ($this->getRequest()->getMethod() == 'POST')
            {
                  $form->bindRequest( $this->getRequest() );
                  if ($form->isValid())
                  {
                        $em = $this->getDoctrine()->getEntityManager();
                        $em->persist( $form->getData() );
                        $em->flush();
                  }
            }
<?php

namespace Gaoren\VendorsBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class VendorImageType extends AbstractType
{

      public function buildForm(FormBuilderInterface $builder, array $options)
      {
            $builder
                    ->add( 'address' );
                    ->add( 'telephone');
                    ->add( 'image_identification');
      }

      public function getName()
      {
            return 'gaoren_vendors_product';
      }

}