You are here

function theme_ingredients_form in Recipe 6

Same name and namespace in other branches
  1. 7 recipe.module \theme_ingredients_form()
1 theme call to theme_ingredients_form()
recipe_form in ./recipe.module
Implementation of hook_form().

File

./recipe.module, line 408
recipe.module - share recipes

Code

function theme_ingredients_form($form) {
  $header = array(
    '',
    t('Quantity'),
    t('Units'),
    t('Ingredient name'),
    t('Processing/Notes'),
    t('Sort Weight'),
  );
  drupal_add_tabledrag('ingredient-list', 'order', 'sibling', 'ingredient-weight');
  foreach (element_children($form) as $key) {

    // Skip the more ingredients button
    if (is_numeric($key)) {

      // Add class to ingredient weight fields for drag and drop.
      $form[$key]['weight']['#attributes']['class'] = 'ingredient-weight';
      $row = array(
        '',
      );
      $row[] = drupal_render($form[$key]['ri_id']) . drupal_render($form[$key]['quantity']);
      $row[] = drupal_render($form[$key]['unit_id']);
      $row[] = drupal_render($form[$key]['name']);
      $row[] = drupal_render($form[$key]['note']);
      $row[] = drupal_render($form[$key]['weight']);
      $rows[] = array(
        'data' => $row,
        'class' => 'draggable',
      );
    }
  }
  $output = theme('table', $header, $rows, array(
    'id' => 'ingredient-list',
  ));
  $output .= drupal_render($form);
  return $output;
}