class ProductType extends AbstractType
{
  public function buildForm(FormBuilder $builder, array $options)
  {
      $builder->add('name');
      $builder->add('price','money',array('currency'=>'EUR'))
      $builder->add('description');
      $builder->add('idCategory','entity',
                        array('class' =>
'Vendor\YourBundleBundle\Entity\Category',
                            'property' => 'descriptioncategory',
                            'query_builder' => function ($repository) {
return
$repository->createQueryBuilder('p')->orderBy('p.descriptioncategory',
'ASC'); },
                            'label' => 'Category'
                            )
                     );
}

2011/6/7 Thijs <t.vog...@me.com>

> Hi there,
>
> I'm new to Symfony and I'm playing with the product/category-example
> from the doctrine book entry.
> Everything works fine.
> A product belongs to one category. This relationship is defined with
> annotations in the entity objects.
>
> I'm creating a product-form like this:
>
> class ProductType extends AbstractType
> {
>   public function buildForm(FormBuilder $builder, array $options)
>   {
>       $builder->add('name');
>       $builder->add('price','money',array('currency'=>'EUR'));
>       $builder->add('description');
>   }
> }
>
> Is it possible to generate a select-widget to choose the category from
> all available categories?
>
> Thanks in advance
>
> Thijs
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to