Guest User

Untitled

a guest
Jan 12th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. $zipcode_options = get_all_zipcodes_ascending();
  2.  
  3. // Populate Ort on auktion clone.
  4. $selected = isset($auktion->zip_code) ? $auktion->zip_code : NULL;
  5. $selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected;
  6. $ort_options = _ajax_city_dropdown_options($selected);
  7.  
  8. $form['zip_code'] = [
  9. '#type' => 'select',
  10. '#title' => t('PLZ'),
  11. '#options' => $zipcode_options,
  12. '#default_value' => isset($auktion->zip_code) ? $auktion->zip_code : "",
  13. '#select2' => ['width' => '100%', 'placeholder' => t('Enter a zipcode'), 'allowClear' => TRUE],
  14. '#empty_option' => '',
  15. '#validated' => TRUE,
  16. '#required' => TRUE,
  17. '#ajax' => array(
  18. 'event' => 'change',
  19. 'callback' => 'ajax_example_dependent_dropdown_callback',
  20. 'wrapper' => 'dropdown-second-replace',
  21. ),
  22. ];
  23.  
  24. $selected = isset($auktion->zip_code) ? $auktion->zip_code : NULL;
  25. $selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected;
  26. $ort_options = _ajax_city_dropdown_options($selected);
  27. if(!is_array($ort_options)){
  28. $ort_options=array();
  29. }
Add Comment
Please, Sign In to add comment