You are here

function mvf_ajax in Measured Value Field 7

Menu page callback.

Menu #ajax callback path for any settings form of MVF field.

Parameters

string $type: Current setting on which it's being fired. Normally it holds values like: 'widget_settings' 'formatter_settings' ...etc

string $entity_type: Instanence of what entity type is being edited

string $bundle: Bundle of the entity type

string $field_name: Instance of what field name is being edited. It's easy to retrieve instance definition array and field definition array using all these parameters. This way we should be able to retrieve enough info about context in which the function is called to process any required task

string $subfield: Which subfield is being edited. After retrieving field and instance definition arrays, one might want to pass them on to mvf_field_mockup() and mvf_instance_mockup() functions

Return value

array Array definition of form elements that will be passed to this page callback delivery callback, which is normally ajax_deliver()

1 string reference to 'mvf_ajax'
mvf_menu in ./mvf.module
Implements hook_menu().

File

./mvf.module, line 1818
Define a field type of measured value.

Code

function mvf_ajax($type, $entity_type, $bundle, $field_name, $subfield) {

  // TODO: is it possible to implement it without custom AJAX menu path?
  list($form, $form_state) = ajax_get_form();
  drupal_process_form($form['#form_id'], $form, $form_state);
  switch ($type) {
    case 'formatter':
      return $form['fields'][$field_name]['format']['settings_edit_form']['settings'][$subfield];
      break;
  }
}