You are here

flexiform.module in Flexiform 7

Same filename and directory in other branches
  1. 8 flexiform.module

Module for the Flexiform system.

File

flexiform.module
View source
<?php

/**
 * @file
 * Module for the Flexiform system.
 */

/**
 * Implements hook_hook_info().
 */
function flexiform_hook_info() {
  $hooks['flexiform_group_info'] = array(
    'group' => 'flexiform',
  );
  $hooks['flexiform_builder_info'] = array(
    'group' => 'flexiform',
  );
  $hooks['flexiform_display_info'] = array(
    'group' => 'flexiform',
  );
  $hooks['flexiform_element_info'] = array(
    'group' => 'flexiform',
  );
  $hooks['flexiform_entity_getter_info'] = array(
    'group' => 'flexiform',
  );
  $hooks['flexiform_ajax_submit_commands_alter'] = array(
    'group' => 'flexiform',
  );
  $hooks['flexiform_access'] = array(
    'group' => 'flexiform',
  );
  $hooks['flexiform_submission_access'] = array(
    'group' => 'flexiform',
  );
  $hooks['default_flexiform'] = array(
    'group' => 'flexiform_default',
  );
  $hooks['default_flexiform_alter'] = array(
    'group' => 'flexiform_default',
  );
  return $hooks;
}

/**
 * Implements hook_menu()
 *
 * We want to add a manage form fields tab and a manage form entities tab
 * for each flexiform
 */
function flexiform_menu() {
  $items = array();
  $displays = flexiform_display_info();
  $hook_menu_displays = array();
  foreach ($displays as $name => $info) {
    if (method_exists($info['class'], 'hook_menu')) {
      $hook_menu_displays[] = $name;
    }
  }
  if ($hook_menu_displays) {

    /** @var \FlexiformController $controller */
    $controller = entity_get_controller('flexiform');
    foreach ($controller
      ->loadWithDisplay($hook_menu_displays) as $form) {
      foreach ($hook_menu_displays as $name) {
        if (($display = $form
          ->getDisplay($name)) && $display
          ->isEnabled()) {
          $items += $display
            ->hook_menu();
        }
      }
    }
  }

  // Entityreference autocomplete flexiform.
  if (module_exists('entityreference')) {
    $items['flexiform/entityreference/autocomplete/single/%flexiform/%'] = array(
      'title' => 'Flexiform Entity Reference Autocomplete',
      'page callback' => 'flexiform_entityreference_autocomplete_callback',
      'page arguments' => array(
        3,
        4,
        5,
      ),
      'access callback' => 'flexiform_entityreference_autocomplete_access_callback',
      'access arguments' => array(
        3,
        4,
        5,
      ),
      'file' => 'flexiform.entityreference.inc',
      'type' => MENU_CALLBACK,
    );
    $items['flexiform/entityreference/autocomplete/tags/%flexiform/%'] = array(
      'title' => 'Flexiform Entity Reference Autocomplete',
      'page callback' => 'flexiform_entityreference_autocomplete_callback',
      'page arguments' => array(
        3,
        4,
        5,
      ),
      'access callback' => 'flexiform_entityreference_autocomplete_access_callback',
      'access arguments' => array(
        3,
        4,
        5,
      ),
      'file' => 'flexiform.entityreference.inc',
      'type' => MENU_CALLBACK,
    );
  }
  return $items;
}

/**
 * Implements hook_menu_alter()
 *
 * Allow displays to alter the menu.
 */
function flexiform_menu_alter(&$items) {
  $displays = flexiform_display_info();
  $hook_menu_displays = array();
  foreach ($displays as $name => $info) {
    if (method_exists($info['class'], 'hook_menu_alter')) {
      $hook_menu_displays[] = $name;
    }
  }
  if ($hook_menu_displays) {

    /** @var \FlexiformController $controller */
    $controller = entity_get_controller('flexiform');
    foreach ($controller
      ->loadWithDisplay($displays) as $form) {
      foreach ($hook_menu_displays as $name) {
        if (($display = $form
          ->getDisplay($name)) && $display
          ->isEnabled()) {
          $display
            ->hook_menu_alter($items);
        }
      }
    }
  }

  // Alter comment bits.
  // Adjust the Field UI tabs on admin/structure/types/manage/[node-type].
  // See comment_entity_info().
  if (!empty($items['admin/structure/types/manage/%comment_node_type/comment/fields']['title'])) {
    $items['admin/structure/types/manage/%comment_node_type/comment/fields']['title'] = 'Comment fields';
    $items['admin/structure/types/manage/%comment_node_type/comment/fields']['weight'] = 4;
  }
  if (!empty($items['admin/structure/types/manage/%comment_node_type/comment/display']['title'])) {
    $items['admin/structure/types/manage/%comment_node_type/comment/display']['title'] = 'Comment display';
    $items['admin/structure/types/manage/%comment_node_type/comment/display']['weight'] = 5;
  }
  if (!empty($items['admin/structure/types/manage/%comment_node_type/comment/forms']['title'])) {
    $items['admin/structure/types/manage/%comment_node_type/comment/forms']['title'] = 'Comment forms';
    $items['admin/structure/types/manage/%comment_node_type/comment/forms']['weight'] = 6;
  }
}

/**
 * Implements hook_user_categories()
 *
 * Add any user categories being created by flexiforms.
 */
function flexiform_user_categories() {
  $categories = array();

  /** @var \FlexiformController $controller */
  $controller = entity_get_controller('flexiform');
  foreach ($controller
    ->loadWithDisplay('FlexiformDisplayUserCategory') as $form) {
    $display = $form
      ->getDisplay('FlexiformDisplayUserCategory');
    $categories = array_merge($categories, $display
      ->hook_user_categories());
  }
  return $categories;
}

/**
 * Implement hook_entity_info().
 *
 * We define two entities here - the actual entity that will hold our domain
 * specific information and an entity that holds information about the different
 * types of entities. See here: http://drupal.org/node/977380 for a discussion on this
 * choice.
 */
function flexiform_entity_info() {

  // The entity that holds information about the entity types
  $return['flexiform'] = array(
    'label' => t('Flexible Form'),
    'entity class' => 'Flexiform',
    'controller class' => 'FlexiformController',
    'base table' => 'flexiform',
    'fieldable' => FALSE,
    'exportable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'name' => 'form',
      'label' => 'label',
    ),
    'access callback' => 'flexiform_access',
    'module' => 'flexiform',
    // Enable the entity API's admin UI.
    'admin ui' => array(
      'path' => 'admin/structure/flexiforms',
      'file' => 'flexiform.admin.inc',
      'controller class' => 'FlexiformUIController',
    ),
  );
  return $return;
}

/**
 * Implements hook_views_api().
 */
function flexiform_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'flexiform') . '/includes/views',
  );
}

/**
 * Impements hook_ctools_plugin_directory().
 */
function flexiform_ctools_plugin_directory($owner, $plugin_type) {
  if ($owner == 'panelizer' && $plugin_type == 'entity') {
    return "plugins/{$plugin_type}";
  }
  if ($owner == 'ctools' && $plugin_type == 'content_types') {
    return "plugins/{$plugin_type}";
  }
}

/**
 * Implements hook_permission().
 */
function flexiform_permission() {

  // We set up permisssions to manage entity types, manage all entities and the
  // permissions for each individual entity
  $permissions = array(
    'administer flexiforms' => array(
      'title' => t('Administer flexiforms'),
      'description' => t('Create and delete fields for flexiforms, and set their permissions.'),
    ),
  );
  return $permissions;
}

/**
 * Access callback for the entity API.
 */
function flexiform_access($op, $flexiform = NULL, $account = NULL) {
  if (user_access('administer flexiforms', $account)) {
    return TRUE;
  }

  // Allow modules to grant / deny access.
  $access = module_invoke_all('flexiform_access', $op, $flexiform, $account);

  // Only grant access if at least one module granted access and no one denied
  // access.
  if (in_array(FALSE, $access, TRUE)) {
    return FALSE;
  }
  elseif (in_array(TRUE, $access, TRUE)) {
    return TRUE;
  }
  return FALSE;
}

/**
 * Access callback for widget type form.
 */
function flexiform_field_widget_type_form_access($flexiform, $element_namespace) {
  $element = FlexiformElement::getElement($flexiform, $element_namespace);
  return $element instanceof FlexiformElementFieldAPIInterface && user_access('administer flexiforms');
}

/**
 * Gets an array of all flexiforms, keyed by the type name.
 *
 * @param $type_name
 *   If set, the type with the given name is returned.
 * @return Flexiform[]
 *   Depending whether $type isset, an array of flexiforms or a single one.
 */
function flexiform_get_flexiforms($flexiform_name = NULL) {

  // entity_load will get the Entity controller for our flexiform_submission entity and call the load
  // function of that object - we are loading entities by name here.
  $flexiforms = entity_load_multiple_by_name('flexiform', isset($flexiform_name) ? array(
    $flexiform_name,
  ) : FALSE);
  return isset($flexiform_name) ? reset($flexiforms) : $flexiforms;
}

/**
 * Gets an array of all flexiforms with a given base_entity type and bundle.
 *
 * @param string $entity_type
 *   The entity type of base entity.
 * @param string $bundle
 *   The bundle of the base entity.
 *
 * @return array
 *   An array of flexiforms.
 */
function flexiform_get_base_entity_forms($entity_type, $bundle = FALSE) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'flexiform');
  $query
    ->propertyCondition('base_entity', $entity_type);
  if ($bundle) {
    $query
      ->propertyCondition('base_entity_bundle', $bundle);
  }
  $entities = $query
    ->execute();
  if (empty($entities['flexiform'])) {
    return array();
  }
  return entity_load('flexiform', array_keys($entities['flexiform']));
}

/**
 * Menu argument loader; Load a flexiform by string.
 *
 * @param $form
 *   The machine-readable name of a flexiform to load.
 *
 * @return
 *   A flexiform array or FALSE if $type does not exist.
 */
function flexiform_load($form) {
  return flexiform_get_flexiforms($form);
}

/**
 * Saves a flexiform to the db.
 */
function flexiform_save(Flexiform $form) {
  $form
    ->save();
}

/**
 * Deletes a flexiform from the db.
 */
function flexiform_delete(Flexiform $form) {
  $form
    ->delete();
}

/**
 * Split a namespace into entity and field name
 */
function flexiform_formfield_load($string) {
  return $string;
}

/**
 * Implement hook_theme().
 */
function flexiform_theme() {
  return array(
    'flexiform' => array(
      'render element' => 'element',
      'template' => 'flexiform',
    ),
    'flexiform_field_table' => array(
      'render element' => 'elements',
    ),
    'flexiform_entity_table' => array(
      'render element' => 'elements',
    ),
    'flexiform_ui_overview_item' => array(
      'variables' => array(
        'label' => NULL,
        'entity_type' => NULL,
        'url' => FALSE,
        'name' => FALSE,
        'tags' => FALSE,
      ),
      'file' => 'flexiform.admin.inc',
    ),
  );
}

/**
 * Preprocessor for flexiforms.
 */
function template_preprocess_flexiform(&$variables) {
  $variables['form'] = drupal_render_children($variables['element']);
  $variables['form_html_id'] = 'flexiform--' . $variables['element']['#id'];
}

/**
 * Implements hook_forms().
 */
function flexiform_forms($form_id, $args) {
  $forms = array();
  $parts = explode('__', $form_id);
  if ($parts[0] == 'flexiform') {
    $forms[$form_id] = array(
      'callback' => 'flexiform',
      'wrapper_callback' => 'flexiform_form_wrapper',
    );
  }
  return $forms;
}

/**
 * Flexiform Form Wrapper to ensure that the flexiform include file is always present.
 */
function flexiform_form_wrapper($form, &$form_state) {
  form_load_include($form_state, 'inc', 'flexiform', 'includes/flexiform.flexiform');
  return $form;
}

/**
 * Implements hook_element_info().
 */
function flexiform_element_info() {
  return array(
    'flexiform_field_table' => array(
      '#theme' => 'flexiform_field_table',
      '#pre_render' => array(
        'flexiform_field_table_pre_render',
      ),
      '#regions' => array(
        '' => array(),
      ),
    ),
    'flexiform_entity_table' => array(
      '#theme' => 'flexiform_entity_table',
      '#pre_render' => array(
        'flexiform_entity_table_pre_render',
      ),
      '#regions' => array(
        '' => array(),
      ),
    ),
  );
}

/**
 * Retreive a list of flexiform groups.
 */
function flexiform_get_groups() {
  $groups =& drupal_static(__FUNCTION__, NULL);
  if ($groups === NULL) {
    $groups = module_invoke_all('flexiform_group_info');
  }
  return $groups;
}

/**
 * Title Callback for Flexiform Submission Pages.
 */
function flexiform_page_title($flexiform, $display, $base_entity_id = NULL) {
  if (!is_object($flexiform)) {
    $flexiform = flexiform_load($flexiform);
  }
  if (!$flexiform) {
    return FALSE;
  }
  $context = array(
    'base_entity_id' => $base_entity_id,
  );
  return $flexiform
    ->getDisplay($display)
    ->title($context);
}

/**
 * Access callback for flexiform pages.
 */
function flexiform_page_access($flexiform, $display, $base_entity_id = NULL) {
  if (!is_object($flexiform)) {
    $flexiform = flexiform_load($flexiform);
  }
  if (!$flexiform) {
    return FALSE;
  }
  $context = array(
    'base_entity_id' => $base_entity_id,
  );
  return $flexiform
    ->getDisplay($display)
    ->access($context);
}

/**
 * Access callback for modal pages.
 */
function flexiform_modal_page_access($flexiform, $display, $js, $base_entity_id = NULL) {
  return flexiform_page_access($flexiform, $display, $base_entity_id);
}

/**
 * Access callback for flexiform user categories.
 */
function flexiform_user_category_access($flexiform, $display, $user) {
  if (!is_object($flexiform)) {
    $flexiform = flexiform_load($flexiform);
  }
  if (!$flexiform) {
    return FALSE;
  }
  $context = array(
    'base_entity_id' => $user,
  );
  return user_edit_access($user) && $flexiform
    ->getDisplay($display)
    ->access($context);
}

/**
 * Implements hook_field_create_instance().
 */
function flexiform_field_create_instance() {

  // Clear the element cache.
  flexiform_get_element_info('', '', '', TRUE);
}

//-----------------------------------------------------------------------------

// Flexiform Builder API

/**
 * Get info about all available builders.
 */
function flexiform_builder_info($builder = NULL) {
  $builders =& drupal_static(__FUNCTION__, array());
  if (empty($builders)) {
    if ($cache = cache_get('flexiform:builder_info', 'cache')) {
      $builders = $cache->data;
    }
    else {
      $builders = array();
      foreach (module_implements('flexiform_builder_info') as $module) {

        // Due to http://drupal.org/node/890660 we can't use module_invoke_all()
        // because we need to know the provenance of each set.
        $builders_module = module_invoke($module, 'flexiform_builder_info');
        foreach ($builders_module as $builder_name => $builder_info) {
          $builder_info += array(
            'class' => $builder_name,
            'label' => $builder_name,
            'module' => $module,
            'entity_types' => array(),
          );
          $builders[$builder_name] = $builder_info;
        }
      }

      // Alter the data sets with hook_party_data_set_info_alter().
      drupal_alter('flexiform_builder_info', $builders);
      cache_set('flexiform:builder_info', $builders);
    }
  }
  if (!empty($builder)) {
    return $builders[$builder];
  }
  return $builders;
}

/**
 * Get the builders available for a particular base entity type.
 */
function flexiform_entity_type_get_builders($entity_type) {

  // If this isn't an entity type return false
  if (!entity_get_info($entity_type)) {
    return FALSE;
  }
  $builders = flexiform_builder_info();
  $applicable_builders = array();
  foreach ($builders as $builder => $info) {
    if (empty($info['entity_types']) || in_array($entity_type, $info['entity_types'])) {
      $applicable_builders[$builder] = $info;
    }
  }
  return $applicable_builders;
}

/**
 * Access callback for form-entities and form-fields tabs that are only
 * available for some builders.
 *
 * @param Flexiform $flexiform
 *   The flexiform to check.
 * @param string $component
 *   The component to check access for, normally 'elements' or 'entities'
 */
function flexiform_builder_admin_access($flexiform, $component) {
  return user_access('administer flexiforms') && $flexiform
    ->getBuilder()
    ->supportsComponent($component);
}

//-----------------------------------------------------------------------------

// Entity Getter and Setter API

/**
 * Get info about all entity getters
 */
function flexiform_entity_getter_info($getter = NULL) {
  $getters =& drupal_static(__FUNCTION__);
  if (!isset($getters)) {
    if ($cache = cache_get('flexiform:entity_getter_info', 'cache')) {
      $getters = $cache->data;
    }
    else {
      $getters = array();
      foreach (module_implements('flexiform_entity_getter_info') as $module) {

        // Due to http://drupal.org/node/890660 we can't use module_invoke_all()
        // because we need to know the provenance of each set.
        $getters_module = module_invoke($module, 'flexiform_entity_getter_info');
        foreach ($getters_module as $getter_name => $getter_info) {
          $getter_info += array(
            'params' => array(),
            'module' => $module,
          );
          if (!isset($getter_info['class'])) {
            $getter_info['class'] = 'FlexiformFormEntityLegacy';
            $getter_info += array(
              'getter callback' => 'flexiform_entity_getter_' . $getter_name,
              'setter callback' => 'flexiform_entity_setter_' . $getter_name,
              'file' => $module . '.flexiform.inc',
            );
          }
          $getters[$getter_name] = $getter_info;
        }
      }

      // Alter the data sets with hook_party_data_set_info_alter().
      drupal_alter('flexiform_entity_getter_info', $getters);
      cache_set('flexiform:entity_getter_info', $getters);
    }
  }
  if (!empty($getter)) {
    return $getters[$getter];
  }
  return $getters;
}

/**
 * Get the getters for a particular entity type
 */
function flexiform_entity_type_get_getters($entity_type) {

  // If this isn't an entity type return false
  if (!entity_get_info($entity_type)) {
    return FALSE;
  }
  $getters = flexiform_entity_getter_info();
  $applicable_getters = array();
  foreach ($getters as $getter => $info) {
    if (in_array($entity_type, $info['entity_types'])) {
      $applicable_getters[$getter] = $info;
    }
  }
  return $applicable_getters;
}

//-----------------------------------------------------------------------------

// Flexiform Element API

/**
 * Get information about flexiform elements.
 */
function flexiform_get_element_info($entity_type = '', $bundle = '', $name = '', $reset = FALSE) {
  $elements =& drupal_static(__FUNCTION__);
  if (!isset($elements) || $reset) {
    if (($cache = cache_get('flexiform:element_info', 'cache')) && !$reset) {
      $elements = $cache->data;
    }
    else {
      $elements = array();
      $elements = module_invoke_all('flexiform_element_info');

      // Make sure the entity_type, bundle and name are set.
      foreach ($elements as $entity_type_ => $elems) {
        foreach ($elems as $bundle_ => $els) {
          foreach ($els as $name_ => $element) {
            $elements[$entity_type_][$bundle_][$name_] += array(
              'entity_type' => $entity_type_,
              'bundle' => $bundle_,
              'name' => $name_,
              'group' => 'Other',
            );
          }
        }
      }

      // Alter the data sets with hook_party_data_set_info_alter().
      drupal_alter('flexiform_element_info', $elements);
      cache_set('flexiform:element_info', $elements);
    }
  }
  if (!empty($entity_type)) {
    if (!empty($bundle)) {
      if (!empty($name)) {
        return isset($elements[$entity_type][$bundle][$name]) ? $elements[$entity_type][$bundle][$name] : FALSE;
      }
      return isset($elements[$entity_type][$bundle]) ? $elements[$entity_type][$bundle] : FALSE;
    }
    return isset($elements[$entity_type]) ? $elements[$entity_type] : FALSE;
  }
  return $elements;
}

//-----------------------------------------------------------------------------

// Flexiform Display API

/**
 * Get information about flexiform displays.
 */
function flexiform_display_info($display = FALSE) {
  $displays =& drupal_static(__FUNCTION__, array());
  if (empty($displays)) {
    if ($cache = cache_get('flexiform:display_info', 'cache')) {
      $displays = $cache->data;
    }
    else {
      $displays = array();
      foreach (module_implements('flexiform_display_info') as $module) {

        // Due to http://drupal.org/node/890660 we can't use module_invoke_all()
        // because we need to know the provenance of each set.
        $displays_module = module_invoke($module, 'flexiform_display_info');
        foreach ($displays_module as $display_name => $display_info) {
          $display_info += array(
            'class' => $display_name,
            'label' => $display_name,
            'module' => $module,
            'entity_types' => array(),
          );
          $displays[$display_name] = $display_info;
        }
      }

      // Alter the data sets with hook_party_data_set_info_alter().
      drupal_alter('flexiform_display_info', $displays);
      cache_set('flexiform:display_info', $displays);
    }
  }
  if (!empty($display)) {
    return empty($displays[$display]) ? FALSE : $displays[$display];
  }
  return $displays;
}

/**
 * Get display plugins for a particular entity type.
 */
function flexiform_entity_type_get_displays($entity_type) {

  // If this isn't an entity type return false
  if (!entity_get_info($entity_type)) {
    return FALSE;
  }
  $displays = flexiform_display_info();
  $applicable_displays = array();
  foreach ($displays as $display => $info) {
    if (empty($info['entity_types']) || in_array($entity_type, $info['entity_types'])) {
      $applicable_displays[$display] = $info;
    }
  }
  return $applicable_displays;
}

/**
 * Display a flexiform.
 */
function flexiform_display($flexiform, $display, $context = array()) {
  return $flexiform
    ->getDisplay($display)
    ->build($context);
}

/**
 * Implements hook_ctools_access_get.
 */
function flexiform_ctools_access_get($argument) {
  $flexiform = flexiform_load($argument);
  try {
    $contexts = $flexiform
      ->getAccessController()
      ->prepareContexts();
  } catch (Exception $e) {
    return array();
  }
  return array(
    $flexiform
      ->getAccessController()
      ->getCtoolsSettings(),
    $contexts,
  );
}

/**
 * Implements hook_ctools_access_set().
 */
function flexiform_ctools_access_set($argument, $access) {
  $flexiform = flexiform_load($argument);
  $flexiform
    ->getAccessController()
    ->setCtoolsSettings($access);
}

/**
 * Access callback for flexiform entityreference autocomplete.
 */
function flexiform_entityreference_autocomplete_access_callback($type, $flexiform, $element_namespace) {
  try {
    $element = FlexiformElement::getElement($flexiform, $element_namespace);
    $element_field = $element
      ->getField();
    if ($element_field['type'] != 'entityreference') {
      return FALSE;
    }

    // @todo: Check Flexiform Access.
    return TRUE;
  } catch (Exception $e) {
    return FALSE;
  }
}

/**
 * Implements hook_flexiform_build_alter().
 */
function flexiform_flexiform_build_alter(&$form, &$form_state, $flexiform) {

  // Manually adding support for field_collection's
  // "field_collection_field_attach_form" hook that the
  // Flexiform builder doesn't invoke.
  foreach ($flexiform->elements as $element_namespace => $element_info) {

    // If we're not dealing with a field (i.e.: potentially a property),
    // then skip this element.
    if (!isset($element_info['field_name'])) {
      continue;
    }
    $field_name = $element_info['field_name'];
    $field = field_info_field($field_name);
    $element =& $form[$element_namespace];
    $entity_info = $flexiform->entities[$element_info['entity_namespace']];
    $entity_type = $entity_info['entity_type'];
    if ($field['type'] == 'field_collection') {
      $instance = field_info_instance($entity_type, $field_name, $entity_info['bundle']);

      // Can access the field and is target widget type?
      if (field_access('edit', $field, $entity_type) && in_array($instance['widget']['type'], array(
        'field_collection_embed',
        'field_collection_table',
      ))) {
        if (field_collection_hide_blank_items($field)) {
          $element_langcode = $element['#language'];
          if ($element[$element_langcode]['#max_delta'] > 0) {
            $element[$element_langcode]['#max_delta']--;
          }

          // Remove blank form elements and force user to explicitly add a field
          // collection if both 'hide_initial_item' and 'hide_blank_items' are TRUE.
          if ($field['settings']['hide_initial_item'] && $field['settings']['hide_blank_items'] && field_collection_item_is_empty($element[$element_langcode][0]['#entity'])) {
            _field_collection_process_children_attached($element[$element_langcode][0]);
            unset($element[$element_langcode][0]);
            unset($form_state['field']['#parents'][$field_name][$element_langcode][0]);
          }
        }
        if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
          $element_langcode = $element['#language'];
          $element_wrapper = $element[$element_langcode]['add_more']['#ajax']['wrapper'];
          for ($i = 0; $i <= $element[$element_langcode]['#max_delta']; $i++) {
            if (isset($element[$element_langcode][$i]['remove_button'])) {
              $element[$element_langcode][$i]['remove_button']['#ajax']['wrapper'] = $element_wrapper;
            }
          }
        }
      }
    }
  }
}

Functions

Namesort descending Description
flexiform_access Access callback for the entity API.
flexiform_builder_admin_access Access callback for form-entities and form-fields tabs that are only available for some builders.
flexiform_builder_info Get info about all available builders.
flexiform_ctools_access_get Implements hook_ctools_access_get.
flexiform_ctools_access_set Implements hook_ctools_access_set().
flexiform_ctools_plugin_directory Impements hook_ctools_plugin_directory().
flexiform_delete Deletes a flexiform from the db.
flexiform_display Display a flexiform.
flexiform_display_info Get information about flexiform displays.
flexiform_element_info Implements hook_element_info().
flexiform_entityreference_autocomplete_access_callback Access callback for flexiform entityreference autocomplete.
flexiform_entity_getter_info Get info about all entity getters
flexiform_entity_info Implement hook_entity_info().
flexiform_entity_type_get_builders Get the builders available for a particular base entity type.
flexiform_entity_type_get_displays Get display plugins for a particular entity type.
flexiform_entity_type_get_getters Get the getters for a particular entity type
flexiform_field_create_instance Implements hook_field_create_instance().
flexiform_field_widget_type_form_access Access callback for widget type form.
flexiform_flexiform_build_alter Implements hook_flexiform_build_alter().
flexiform_formfield_load Split a namespace into entity and field name
flexiform_forms Implements hook_forms().
flexiform_form_wrapper Flexiform Form Wrapper to ensure that the flexiform include file is always present.
flexiform_get_base_entity_forms Gets an array of all flexiforms with a given base_entity type and bundle.
flexiform_get_element_info Get information about flexiform elements.
flexiform_get_flexiforms Gets an array of all flexiforms, keyed by the type name.
flexiform_get_groups Retreive a list of flexiform groups.
flexiform_hook_info Implements hook_hook_info().
flexiform_load Menu argument loader; Load a flexiform by string.
flexiform_menu Implements hook_menu()
flexiform_menu_alter Implements hook_menu_alter()
flexiform_modal_page_access Access callback for modal pages.
flexiform_page_access Access callback for flexiform pages.
flexiform_page_title Title Callback for Flexiform Submission Pages.
flexiform_permission Implements hook_permission().
flexiform_save Saves a flexiform to the db.
flexiform_theme Implement hook_theme().
flexiform_user_categories Implements hook_user_categories()
flexiform_user_category_access Access callback for flexiform user categories.
flexiform_views_api Implements hook_views_api().
template_preprocess_flexiform Preprocessor for flexiforms.