jeudi 1 juin 2017

How can I create a checkBox - Silex framework

I'm using a Silex framework. I want change an inputText by a checkBox for multiple choice. This following my code:

$app->get('/Chart/{A}/{B}/{C}/{D}', function(Request $request, $A, $B, $C, $D) use ($app) {

if ($app['security']->isGranted('ROLE_USER')) {
        ///start form 
        $user = $app['security']->getToken()->getUser();
        $form = $app['form.factory']->createBuilder('form')->setMethod('GET')

         ->add('Article', 'text', array(
                    'data' => '',
                    'required' => FALSE))

I changed it by:

->add('Article', 'choice', array(

'choices' => array('A' => 'B',
                        'B' => 'B',
                        'C' => 'C',
                        'D' => 'D',
                        'OTHERS' => 'OTHERS'),
                    'required' => FALSE,
                    'empty_value' => 'ALL',
                    'empty_data' => NULL
                ))

But this one is for a unique choice. How can I change it to a checkbox for multiple choice ? Thank you.




Aucun commentaire:

Enregistrer un commentaire