webform_validation_rule_save

  1. webform_validation
    1. 7
    2. 6
Versions
6 – 7 webform_validation_rule_save($values)

Save a validation rule. Data comes from the admin form or nodeapi function in case of node clone

Code

./webform_validation.module, line 326

<?php
function webform_validation_rule_save($values) {
  // save rules data
  if ($values['action'] == 'add') {
    drupal_write_record('webform_validation_rule', $values);
    $ruleid = $values['ruleid'];
    if ($ruleid && array_filter($values['rule_components'])) {
      webform_validation_save_rule_components($ruleid, array_filter($values['rule_components']));
      module_invoke_all('webform_validation', 'rule', 'add', $values);
    }
  }

  if ($values['action'] == 'edit') {
    drupal_write_record('webform_validation_rule', $values, 'ruleid');
    $ruleid = $values['ruleid'];
    // delete earlier component records for this rule id*/
    db_delete('webform_validation_rule_components')
    ->condition('ruleid', $ruleid)
    ->execute();
    if ($components = array_filter($values['rule_components'])) {
      webform_validation_save_rule_components($ruleid, $components);
      module_invoke_all('webform_validation', 'rule', 'edit', $values);
    }
  }
}
?>