Advertisement
Guest User

Untitled

a guest
Dec 14th, 2011
224
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function my_module_form_alter($form, $form_state)
  3. {
  4.     //...
  5.     $form['field_temp_age'] = array(
  6.         '#type' => 'textfield',
  7.         '#title' => "Player's age on April, 31st",
  8.         '#size' => 10,
  9.         '#require' => TRUE,
  10.         '#suffix' => '<div id = "product-info-ajax-wrapper"></div>',
  11.         '#ajax' => array(
  12.             'wrapper' => 'product-info-ajax-wrapper',
  13.             'callback' => 'ajax_reg_season_product_info',
  14.         ),
  15.     );
  16.     if (!empty($form_state['values']['field_temp_age']))   
  17.     {
  18.         $form['field_dob']['#type'] = 'container';
  19.         //get product assignment title & description
  20.         $form['reg_season_ajax']['#type'] = 'fieldset';
  21.         $result = db_query('SELECT body_value, node.title
  22.                             FROM field_data_body
  23.                             JOIN node
  24.                             ON (field_data_body.entity_id = node.nid)
  25.                             JOIN field_data_field_min_age
  26.                             ON (field_data_body.entity_id=field_data_field_min_age.entity_id)
  27.                             JOIN field_data_field_max_age
  28.                             ON (field_data_body.entity_id=field_data_field_max_age.entity_id)
  29.                             WHERE :1 >= field_min_age_value AND :1 <= field_max_age_value; ',
  30.                             array(':1' => $form_state['values']['field_temp_age']))->fetchAll();
  31.         $form['reg_season_ajax']['league_assignment']['title'] = array(
  32.             '#prefix' => '<div class = "season-title">',
  33.             '#markup' => '<h4>' . $result[0]->title . '</h4>',
  34.         );     
  35.         $form['reg_season_ajax']['league_assignment']['description'] = array(
  36.             '#markup' => '<span class = "season-description">' . $result[0]->body_value . '</span>',
  37.             '#suffix' => '</div>',
  38.         );         
  39.         $form['reg_season_ajax']['volunteer'] = array(
  40.             '#type' => 'fieldset',
  41.             '#title' => 'Volunteer',
  42.         );
  43.     }
  44. }
  45.    
  46. function get_winter_instruction($age)
  47. {
  48.     $result = db_query('SELECT field_data_field_min_age.entity_id FROM field_data_field_min_age JOIN field_data_field_max_age ON (field_data_field_min_age.entity_id = field_data_field_max_age.entity_id) WHERE field_data_field_min_age.field_min_age_value <= :1 AND field_data_field_max_age.field_max_age_value >= :1 AND field_data_field_min_age.bundle = :2', array(':1' => $adj_age, ':2' => 'winter_clinics'))->fetchAll();
  49.     foreach ($result as $record) $eids[] = $record->entity_id;
  50.     $products = commerce_product_load_multiple($eids);
  51.     foreach ($products as $product) $nids[] = $product->field_clinic_reference['und'][0]['nid'];
  52.     $result2 = db_query('SELECT body_value FROM field_data_body WHERE entity_id IN (:1)', array(':1' => $nids))->fetchAll();
  53.     $i = 0;
  54.     foreach ($products as $product)
  55.     {
  56.         if (isset($result2[$i]->body_value)) $product->body = $result2[$i]->body_value;
  57.         $i++;
  58.     }
  59.     return $products;
  60. }
Advertisement
RAW Paste Data Copied
Advertisement