You are here

function conditional_fields_states_handler_link_field in Conditional Fields 7.3

States handler for links provided by the Link module.

File

./conditional_fields.module, line 1882
Define dependencies between fields based on their states and values.

Code

function conditional_fields_states_handler_link_field($field, $field_info, $options, &$state) {
  $link_selectors = array();
  $regex = $options['values_set'] == CONDITIONAL_FIELDS_DEPENDENCY_VALUES_REGEX;

  // Add a condition for each link part (Title and URL)
  if ($field_info['instance']['settings']['title'] == 'optional' || $field_info['instance']['settings']['title'] == 'required') {
    $link_selectors[conditional_fields_field_selector($field['title'])] = array(
      'value' => $regex ? $options['value'] : $options['value_form'][0]['title'],
    );
  }
  $link_selectors[conditional_fields_field_selector($field['url'])] = array(
    'value' => $regex ? $options['value'] : $options['value_form'][0]['url'],
  );
  $state = array(
    $options['state'] => $link_selectors,
  );
}