Hello,

Trying to get works *unique_field* module (D6 version) with Date/Calendar modules, i've faced with problem which I can't resolve. The case: Uniqie_field module checks combination of CCK fields (Date and, say, text field) and, if such combination exists (was added earlier), module returns error message and prevents node to be submitted, highliting wrong fields with red. BUT. It works only when we edit node. When we try to create new node, module displays the error message, but allows new node to be created.

Assuming something wrong with op=validate, I tried to use all possible nodeapi combinations to prevent new nodes creation and finally this piece of code looks like this:

/*start*/
function unique_field_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  // check fields for unique requirements on node 'validate' operation 
$op=='validate' || $op == 'presave' ||  $op == 'insert' || $op == 'prepare' || $op == 'load' || $op == 'update' || $op == 'submit' {

/* skipped ... */

      foreach ($errfld as $field) {
          form_set_error($field, t($errmsg, array('@label' => $labels[$field], '@labels' => join(', ', $labels))));
        }
      }
    }
  }
} 
/*end*/

*skipped* code has 80 lines, so i doubts it's appropriate to post it all here.

Som the question is: where should I start to find decision? Unfortunately, module author seems to have no interest to maintain module any longer.

Thank you for help and suggestions!

Comments

barrett’s picture

You seem to be missing the if clause around your conditionals

if($op=='validate' || $op == 'presave' ||  $op == 'insert' || $op == 'prepare' || $op == 'load' || $op == 'update' || $op == 'submit') {

  /*.....everything else......*/
}
yurg’s picture

Barret, thank you for connsideration. Unfortunately, it was not an issue. Just tested: it still creates nodes, although displays the error message. Anyway, thank you for your time.

In case someone will want to help, full module can be found here: http://drupal.org/files/issues/unique_field-d6-untested-deadwood-port.tgz (i've made d6 port and report it here-> #296520: upgrade to 6?).

--
gomankov.ru/drupal