vendredi 30 juin 2017

How to create a checkbox for multiple choice on PHP

I have an input field I changed it to a checkbox for multiple choices. The worry here I can't add the checkbox, I mean that my user should click on Ctrl and select on the same time several choices. You can see it in this Image:

enter image description here

This following my code of the form:

$app->get('/Chart/{currency}/{year}/{zone}/{lru}....... , function(Request $request,...... $repsite, $lru, $contract, $forecast) use ($app) {
if ($app['security']->isGranted('ROLE_USER')) {
    ///start form 
    $user = $app['security']->getToken()->getUser();        
    $form = $app['form.factory']->createBuilder('form')->setMethod('GET')
    .
    .
    .
    .
 ->add('lru', 'choice', array(
                    'choices' => array(                 

                    '\'ATSU\'' => 'ATSU',
                    '\'APCC\'' => 'APCC',
                       .....
                     ),

                    'required' => FALSE,
                    'empty_value' => 'ALL',
                    'empty_data' => NULL,
                    'multiple' => TRUE                      
                    //'expanded' => TRUE
                ))

I want do a classic checkbox like this on the right:

enter image description here

I did a research on forums I found that I should use multiple and expanded and to set them to TRUE. When I add expanded=TRUE list became very "ugly", I give you a screensheet:

enter image description here

Can you please tell me how can I change my code to do a checkbox for multiple choicelike in the picture above. I hope that I find solution. Thank you.




Aucun commentaire:

Enregistrer un commentaire