1

As drupal assigns title as both id and name to a form element.

$form['wrapper'][$unitClean.'_container'][$unitClean.'_cb'] = array(
                '#type' =>'checkbox', 
                '#title' => t($unit),
                );

I need name and id to be different for checkboxes, textboxes and select lists. Anybody with any idea?

I want to do this because I am populating multiple form elements in a loop, need to manipulate them using JS (in form of groups) and then process them on next page.

0

Found answer, done like this:

$form['wrapper'][$unitClean.'_container'][$unitClean.'_cb'] = array(
                '#type' =>'checkbox', 
                '#title' => t($unit),
                '#attributes' => array(
                  'name' => $unitClean.'_name',
                  'id' => $unitClean.'_id',
                  'onclick' => 'checkall();'                 
                    )
                );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.