Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_module_form_alter($form, $form_state)
- {
- //...
- $form['field_temp_age'] = array(
- '#type' => 'textfield',
- '#title' => "Player's age on April, 31st",
- '#size' => 10,
- '#require' => TRUE,
- '#suffix' => '<div id = "product-info-ajax-wrapper"></div>',
- '#ajax' => array(
- 'wrapper' => 'product-info-ajax-wrapper',
- 'callback' => 'ajax_reg_season_product_info',
- ),
- );
- if (!empty($form_state['values']['field_temp_age']))
- {
- $form['field_dob']['#type'] = 'container';
- //get product assignment title & description
- $form['reg_season_ajax']['#type'] = 'fieldset';
- $result = db_query('SELECT body_value, node.title
- FROM field_data_body
- JOIN node
- ON (field_data_body.entity_id = node.nid)
- JOIN field_data_field_min_age
- ON (field_data_body.entity_id=field_data_field_min_age.entity_id)
- JOIN field_data_field_max_age
- ON (field_data_body.entity_id=field_data_field_max_age.entity_id)
- WHERE :1 >= field_min_age_value AND :1 <= field_max_age_value; ',
- array(':1' => $form_state['values']['field_temp_age']))->fetchAll();
- $form['reg_season_ajax']['league_assignment']['title'] = array(
- '#prefix' => '<div class = "season-title">',
- '#markup' => '<h4>' . $result[0]->title . '</h4>',
- );
- $form['reg_season_ajax']['league_assignment']['description'] = array(
- '#markup' => '<span class = "season-description">' . $result[0]->body_value . '</span>',
- '#suffix' => '</div>',
- );
- $form['reg_season_ajax']['volunteer'] = array(
- '#type' => 'fieldset',
- '#title' => 'Volunteer',
- );
- }
- }
- function get_winter_instruction($age)
- {
- $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();
- foreach ($result as $record) $eids[] = $record->entity_id;
- $products = commerce_product_load_multiple($eids);
- foreach ($products as $product) $nids[] = $product->field_clinic_reference['und'][0]['nid'];
- $result2 = db_query('SELECT body_value FROM field_data_body WHERE entity_id IN (:1)', array(':1' => $nids))->fetchAll();
- $i = 0;
- foreach ($products as $product)
- {
- if (isset($result2[$i]->body_value)) $product->body = $result2[$i]->body_value;
- $i++;
- }
- return $products;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement