I have a content type which has two sets of reference option limit. They are both dead. If I remove one, the other gets alive.

Comments

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

Could you check whether the two ajax elements have distinct classes? Debug this value:

      $settings['ajax_wrapper'] = 'reference-options-limit-' . str_replace('_', '-', $field_name_option_limited);
k4o’s picture

Hi,

I have the same problem. Fields "opponents" and "stages" depend on field "discipline". Only one field works. Both elements have distinct classes and ids.
Second ajax callback is empty.

ajax callback

EDIT:

I found your todo note:
// @todo: I have no idea how to make this work if the triggering field affects
// more than one option limited field!

I change function to:

function reference_option_limit_js($form, $form_state) {
  // Deduce the field the triggering element belongs to.
  // @todo: not sure how robust this is.
  $field_name_triggering = $form_state['triggering_element']['#parents'][0];

  // Find which option limited fields we should be returning the element for.
  $commands = array();
  foreach ($form_state['reference_option_limit'] as $settings) {
    
    if (isset($settings['fields_match'][$field_name_triggering])) {
      $selector = '#reference-options-limit-'.$settings['field'];
      $field = $form[$settings['field']];
      
      if ($messages = theme('status_messages')) {
        $field['messages'] = array(
          '#markup' => '<div class="views-messages">' . $messages . '</div>',
        );
      }
      $commands[] = ajax_command_replace($selector, drupal_render($field));
    }
  }

  return array('#type' => 'ajax', '#commands' => $commands);
}

Please test.

alauddin’s picture

Issue summary: View changes

Hi,

Tested #2 function by replacing the code in reference_option_limit.module - did not work for me.
It even broke the one field that worked.

Anyone get this to work with 2 fields with reference limit from same?

My setup
Vocab A > terms > user selects from list
Vocab B (referenced to A) > terms option limit - works when this is the only one on the form
Vocab C (referenced to A) > terms option limit - does not work.

alauddin’s picture

Ok...found solution in another issue que..with a working patch when applied to dev.

https://drupal.org/comment/8015843#comment-8015843

joachim’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Closing this since the fix is on another issue.