You are here

function content_rules_action_populate_field_submit in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 includes/content.rules.inc \content_rules_action_populate_field_submit()
1 call to content_rules_action_populate_field_submit()
content_rules_field_has_value_submit in includes/content.rules.inc

File

includes/content.rules.inc, line 152
Provides basic rules module support.

Code

function content_rules_action_populate_field_submit(&$settings, $form, &$form_state) {

  // Take over field values and filter out private properties added by CCK
  $settings['value'] = array_filter($form_state['values'][$settings['field_name']], 'is_array');
  foreach ($settings['value'] as $key => $data) {
    foreach (array_filter(array_keys($data)) as $col) {
      if ($col[0] == '_') {
        unset($settings['value'][$key][$col]);
      }
    }
    if ($key && count(array_filter($settings['value'][$key])) == 0) {

      // For multi-valued fields don't check for any additional empty values.
      unset($settings['value'][$key]);
    }
  }
  $settings['code'] = $form_state['values']['code'];
  if (function_exists('rules_action_custom_php_submit')) {

    // Support adding variables to the php code, if php module is present.
    rules_action_custom_php_submit($settings, $form, $form_state);
  }

  // Add all values to the input evaluator, so that textfields / textares can
  // make use of it.
  $names = array(
    'code',
  );
  foreach ($settings['value'] as $key => $data) {
    foreach (array_filter($data, 'is_string') as $col => $value) {
      $names[] = "value|{$key}|{$col}";
    }
  }
  $form_state['element']['#info']['eval input'] = $names;
}