You are here

function multiform_sharedfields_info in Multiple forms 7.2

Return sharedfields info for given multiform.

@todo Store sharedfields info in multiform settings.

1 call to multiform_sharedfields_info()
multiform_sharedfields_process in ./multiform.module
Process sharedfields. Hide dependent sharedfields at form rendering and set their values in _POST after form submission.

File

./multiform.sharedfields.inc, line 9

Code

function multiform_sharedfields_info($multiform) {

  // @todo: Consider the case of multiple multiforms with sharedfields
  // on the same page.
  static $stored_info = array();
  if (!isset($stored_info[$multiform['#multiform_id']])) {
    $stored_info[$multiform['#multiform_id']] = array();

    // Invoke hook_multiform_sharedfields()
    // Modules should return only items for a given multiform_id
    $items = module_invoke_all('multiform_sharedfields', $multiform);
    foreach ($items as $item) {
      $base_index = $item['#base']['#tag'];
      $dependent_index = $item['#dependent']['#tag'];
      if ($base_index && $dependent_index) {
        $item['#base']['#index'] = $base_index;
        $item['#dependent']['#index'] = $dependent_index;
        $stored_info[$multiform['#multiform_id']][] = $item;
      }
    }
  }
  return $stored_info;
}