How to add a new CSS class to a Drupal7 ? Hello I created the following form iterating for each node:

...
$render['my_list'][] = drupal_get_form('shop_form_item_'.$node-&gt;nid, $node-&gt;nid);
...


$render will output the form on the page. The forms will be shop-form-item-20, shop-form-item-21 etc...

function shop_forms($form_id, $args) {
  $forms = array();
      if(strpos($form_id, 'shop_form_item_') === 0) {
        $forms[$form_id] = array('callback' =&gt; 'shop_form',);
      }
  return $forms;
}

function shop_form($form, &amp;$form_state, $nid) {
  $form = array();

    $form['my-item-name'] = array(
    '#type' =&gt; 'hidden',
    '#title' =&gt; t('Name'),
    '#value' =&gt; isset($node-&gt;title) ? $node-&gt;title : '',

  );


  return $form;
}


Now I need to add a class: &lt;form method="post" action="" class="cart"&gt;
How do I insert it?

Thanks
You need to add it to the #attributes key of the $form array:

function shop_form($form, &amp;$form_state, $nid) {
  $form['#attributes']['class'][] = 'cart'; // Classes are added to an array and internally converted to a single string by Drupal later on

  $form['my-item-name'] = array(
    '#type' =&gt; 'hidden',
    '#title' =&gt; t('Name'),
    '#value' =&gt; isset($node-&gt;title) ? $node-&gt;title : '',
  );


  return $form;
}