You are here

function cer_update_right in Corresponding Entity References 7.3

1 string reference to 'cer_update_right'
cer_form in ./cer.admin.inc
Form builder to create or edit presets.

File

./cer.admin.inc, line 34

Code

function cer_update_right(array &$form, array &$form_state) {
  $preset = $form_state['build_info']['args'][0];
  field_attach_submit('cer', $preset, $form, $form_state, array(
    'field_name' => 'cer_left',
  ));
  $left = $preset->wrapper->cer_left->chain
    ->value();
  $left_identifier = $left
    ->__toString();
  $left_re = $left
    ->regex();
  $hierarchy = new FieldHierarchy();
  foreach (CerFieldChain::collectAll() as $chain) {
    if (preg_match($left_re, $chain
      ->__toString()) && preg_match($chain
      ->regex(), $left_identifier)) {
      $hierarchy
        ->addChain($chain);
    }
  }
  $options = $hierarchy
    ->options();
  if ($options) {
    $form['cer_right'][LANGUAGE_NONE]['#options'] = $options;
  }
  else {
    drupal_set_message(t('There are no fields which can correspond with your selection.'), 'warning');
  }
  return $form['cer_right'];
}