Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. function civsearch_property_labels_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  2. if (isset($items[$delta]['label'])) {
  3. $default_label = $items[$delta]['label'];
  4. }
  5.  
  6. if (isset($items[$delta]['value'])) {
  7. $default_value = $items[$delta]['value'];
  8. }
  9.  
  10. // We are unserializing the variable_get because the string that was
  11. // serialized with variable_set was a serialized array. So we need to run the
  12. // unserialize process one more time.
  13. $options = array();
  14. $list_items = unserialize(variable_get('civsearch_property_labels', ''));
  15. foreach ($list_items as $list_item) {
  16. $explode = explode('|', $list_item);
  17. $options[$explode[0]] = $explode[1];
  18. }
  19.  
  20. $labels = $element;
  21. $labels += array(
  22. '#type' => 'select',
  23. '#title' => t('Label'),
  24. '#options' => $options,
  25. '#default_value' => isset($default_label) ? $default_label : '',
  26. '#suffix' => '<br >',
  27. );
  28.  
  29. $values = $element;
  30. $values += array(
  31. '#type' => 'textarea',
  32. '#title' => t('Value'),
  33. '#default_value' => isset($default_value) ? $default_value : '',
  34. );
  35.  
  36. return array(
  37. 'label' => $labels,
  38. 'value' => $values,
  39. );
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement