mercredi 19 octobre 2016

"checkboxes" Form. Output checked ones keys

I'm searching for this problem for a while now, didn't find a answer that works yet. I'm not very good in drupal yet too...

Well...

I have simple Input / Submit form, with various textfields, selects and so on. But also with "checkboxes" (For the weekdays)

[...]

$form['fieldset']['weekday'] = array(
        '#prefix' => '<div class="container-inline">',
        '#type' => 'checkboxes',
        '#options' => array(1 => 'Monday', 
                            2 => 'Tuesday', 
                            3 => 'Wednesday', 
                            4 => 'Thursday', 
                            5 => 'Friday', 
                            6 => 'Saturday', 
                            7 => 'Sunday'),
        '#title' => t('Daysg&emsp;'),
        '#required' => true,    
        '#suffix' => '</div>',
    );

[...]

In the "submit" part of the input form I want to get the numbers saved in a string, divided by ",".

But that's also the problem. For example, if "Monday" and "Tuesday" are checked, I want to get "1" and "2", so I can save them in the string as "1,2"

Hope someone can help me :/




Aucun commentaire:

Enregistrer un commentaire