How to make a select box read-only?

1,397 views
Skip to first unread message

full_metal

unread,
Apr 16, 2012, 1:05:17 AM4/16/12
to sonata...@googlegroups.com
Hi,

Here is my FormMapper 

protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('affiliatePartner', null, array('attr' => array('required' => false, 'widget' => 'single_text', 'readonly' => true)))
    }

It does show a gray read only - select box. But I am still able to change the value. 
I don't mind if it displays the same in a readonly textbox. 

Please find the image attached. 

Thanks,
Amit

full_metal

unread,
Apr 18, 2012, 1:00:28 AM4/18/12
to sonata...@googlegroups.com
Friendly bump. 

Here is the entity definition of the field:

   /**
     * @ORM\ManyToOne(targetEntity="AffiliatePartner")
     */
    protected $affiliatePartner;

full_metal

unread,
Apr 19, 2012, 2:09:05 AM4/19/12
to sonata...@googlegroups.com
Okay, its done this way:
protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('affiliatePartner', null, array('read_only' => true))
    }
Reply all
Reply to author
Forward
0 new messages