Guest User

Untitled

a guest
Apr 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1.  
  2.     // Clone the entity to avoid messing with it.
  3.     $entity_type = $element['#entity_type'];
  4.     if (!isset($form_state[$entity_type])) {
  5.       return;
  6.     }
  7.     $cloned_entity = clone $form_state[$entity_type];
  8.  
  9.     $element['fixed_field'] = field_view_field($entity_type, $cloned_entity, $field['field_name'], $display, $langcode);
  10.     $element['fixed_field']['#ajax'] = array(
  11.       'callback' => 'fixed_field_ajax_get_value',
  12.       'event' => 'click',
  13.       'method' => 'replace',
  14.       'wrapper' => 'fixed_field-div',
  15.     );
  16.     $element['fixed_field']['#prefix'] = '<div id="fixed_field-div">';
  17.     $element['fixed_field']['#suffix'] = '</div>';
  18.     $output = $element;
  19.    
  20.     if (($settings['user_edit_perm']==TRUE) && user_access('edit_fixed_content')) {
  21.       $output['edit'] = array(
  22.         '#markup' => '<input type="button" onclick="alert()" value="'.t('Edit').'" />',
  23.       );
  24.     }
  25.   }
  26.  
  27.   return $output;
  28. }
  29.  
  30. function fixed_field_ajax_get_value($form, $form_state) {
  31.   return array('#markup'=>'qwertyuiop');
  32. }
Add Comment
Please, Sign In to add comment