Hi

there is a bug with CCK user reference module, If i mark it as a required field, then the node can't be submited, it thorows error like that field is required (but it is filled)

I nitoced similar thing in another issues, e.g. filefield, so maybe it is some global bug. However, I could't put it into #problemss with non cck modules because this is core CCK module - user reference.

bye

Comments

With the latest dev, I cannot reproduce exactly this bug.
I have tested these required user reference widgets:
- select (single and multiple)
- autocomplete
- radios
- checkboxes
In no case, I got a "required field" error when the field was not triggered.

I have found another issue though: with the radios widget, if no default value is set, the field is required and triggered, submitting the form without selecting any value will cause an "Illegal option detected" message.

Is that your case?
If not, could you export your content type so that I can test it?

Hello Peter,

Looks like if a radio field is selected as required, it must be triggered and filled, otherwise it shows the error "Illegal option detected". here's the test form that I used. Sorry it's a bit messy, I have many other modules installed. If that doesn't import, I can submit a clean version. My conditional fields version is 2.x dev

$content['type']  = array (
  'name' => 'test',
  'type' => 'test',
  'description' => '',
  'title_label' => 'Title',
  'body_label' => 'Body',
  'min_word_count' => '0',
  'help' => '',
  'node_options' =>
  array (
    'status' => true,
    'promote' => true,
    'sticky' => false,
    'revision' => false,
  ),
  'language_content_type' => '0',
  'old_type' => 'test',
  'orig_type' => '',
  'module' => 'node',
  'custom' => '1',
  'modified' => '1',
  'locked' => '0',
  'multistep_expose' => 'disabled',
  'multistep_steps' => '0',
  'multistep_buttons' => 0,
  'multistep_default' => 'multistep',
  'multistep_extra_title' => 1,
  'multistep_extra_body_field' => 1,
  'multistep_extra_revision_information' => 1,
  'multistep_extra_comment_settings' => 1,
  'multistep_extra_menu' => 1,
  'multistep_extra_path' => 1,
  'multistep_extra_nodewords' => 1,
  'nodewords_edit_metatags' => 1,
  'nodewords_metatags_generation_method' => '0',
  'nodewords_metatags_generation_source' => '2',
  'nodewords_use_alt_attribute' => 1,
  'nodewords_filter_modules_output' =>
  array (
    'imagebrowser' => false,
    'img_assist' => false,
  ),
  'nodewords_filter_regexp' => '',
  'content_profile_use' => 0,
  'comment' => '2',
  'comment_default_mode' => '4',
  'comment_default_order' => '1',
  'comment_default_per_page' => '50',
  'comment_controls' => '3',
  'comment_anonymous' => 0,
  'comment_subject_field' => '1',
  'comment_preview' => '1',
  'comment_form_location' => '0',
  'fivestar' => 0,
  'fivestar_stars' => 5,
  'fivestar_labels_enable' => 1,
  'fivestar_label_0' => 'Cancel rating',
  'fivestar_label_1' => 'Poor',
  'fivestar_label_2' => 'Okay',
  'fivestar_label_3' => 'Good',
  'fivestar_label_4' => 'Great',
  'fivestar_label_5' => 'Awesome',
  'fivestar_label_6' => 'Give it @star/@count',
  'fivestar_label_7' => 'Give it @star/@count',
  'fivestar_label_8' => 'Give it @star/@count',
  'fivestar_label_9' => 'Give it @star/@count',
  'fivestar_label_10' => 'Give it @star/@count',
  'fivestar_style' => 'average',
  'fivestar_text' => 'dual',
  'fivestar_title' => 1,
  'fivestar_feedback' => 1,
  'fivestar_unvote' => 0,
  'fivestar_position_teaser' => 'hidden',
  'fivestar_position' => 'below',
  'inline_registration' => 0,
  'inline_registration_weight' => '-10',
  'ant' => '0',
  'ant_pattern' => '',
  'ant_php' => 0,
  'i18n_newnode_current' => 0,
  'i18n_required_node' => 0,
  'i18n_lock_node' => 0,
  'i18n_node' => 1,
  'i18nsync_nodeapi' =>
  array (
    'name' => false,
    'status' => false,
    'promote' => false,
    'moderate' => false,
    'sticky' => false,
    'revision' => false,
    'parent' => false,
    'taxonomy' => false,
    'comment' => false,
    'locations' => false,
    'field_test_option' => false,
    'field_cond_option_1' => false,
  ),
  'nodewords_nodetype_robots' =>
  array (
    'noindex' => false,
    'nofollow' => false,
    'noarchive' => false,
    'noopd' => false,
    'nosnippet' => false,
    'noydir' => false,
  ),
  'nodewords_nodetype_keywords' => '',
  'nodewords_nodetype_description' => '',
  'nodewords_nodetype_desc_php' => '',
);
$content['fields']  = array (
  0 =>
  array (
    'label' => 'Test option',
    'field_name' => 'field_test_option',
    'type' => 'text',
    'widget_type' => 'optionwidgets_buttons',
    'change' => 'Change basic information',
    'weight' => '31',
    'description' => '',
    'default_value' =>
    array (
      0 =>
      array (
        'value' => '',
      ),
    ),
    'default_value_php' => '',
    'default_value_widget' => NULL,
    'javascript_event' =>
    array (
      'change' => false,
      'blur' => false,
      'dblclick' => false,
      'click' => false,
      'focus' => false,
      'keydown' => false,
      'keyup' => false,
      'keypress' => false,
      'error' => false,
      'mousemove' => false,
      'mousedown' => false,
      'mouseup' => false,
      'submit' => false,
    ),
    'form_markup' =>
    array (
      'prefix' => '',
      'suffix' => '',
    ),
    'group' => false,
    'required' => 1,
    'multiple' => '0',
    'text_processing' => '0',
    'max_length' => '',
    'allowed_values' => '1|option 1
2|option 2
3|option 3',
    'allowed_values_php' => '',
    'op' => 'Save field settings',
    'module' => 'text',
    'widget_module' => 'optionwidgets',
    'columns' =>
    array (
      'value' =>
      array (
        'type' => 'text',
        'size' => 'big',
        'not null' => false,
        'sortable' => true,
        'views' => true,
      ),
    ),
    'controlled_fields' =>
    array (
      'field_cond_option_1' =>
      array (
        2 => '2',
        3 => '3',
      ),
    ),
    'display_settings' =>
    array (
      'label' =>
      array (
        'format' => 'above',
        'exclude' => 0,
      ),
      'teaser' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'full' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      4 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      2 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      3 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'token' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  ),
  1 =>
  array (
    'label' => 'Conditional option 1',
    'field_name' => 'field_cond_option_1',
    'type' => 'text',
    'widget_type' => 'optionwidgets_buttons',
    'change' => 'Change basic information',
    'weight' => '32',
    'description' => '',
    'default_value' =>
    array (
      0 =>
      array (
        'value' => '',
      ),
    ),
    'default_value_php' => '',
    'default_value_widget' =>
    array (
      'field_cond_option_1' =>
      array (
        'value' => '',
      ),
    ),
    'javascript_event' =>
    array (
      'change' => false,
      'blur' => false,
      'dblclick' => false,
      'click' => false,
      'focus' => false,
      'keydown' => false,
      'keyup' => false,
      'keypress' => false,
      'error' => false,
      'mousemove' => false,
      'mousedown' => false,
      'mouseup' => false,
      'submit' => false,
    ),
    'form_markup' =>
    array (
      'prefix' => '',
      'suffix' => '',
    ),
    'group' => false,
    'conditional_fields' =>
    array (
      'available_fields' =>
      array (
        'field_test_option' =>
        array (
          2 => '2',
          3 => '3',
        ),
      ),
    ),
    'required' => 1,
    'multiple' => '0',
    'text_processing' => '0',
    'max_length' => '',
    'allowed_values' => '1|option 1
2|option 2',
    'allowed_values_php' => '',
    'op' => 'Save field settings',
    'module' => 'text',
    'widget_module' => 'optionwidgets',
    'columns' =>
    array (
      'value' =>
      array (
        'type' => 'text',
        'size' => 'big',
        'not null' => false,
        'sortable' => true,
        'views' => true,
      ),
    ),
    'display_settings' =>
    array (
      'label' =>
      array (
        'format' => 'above',
        'exclude' => 0,
      ),
      'teaser' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'full' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      4 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      2 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      3 =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'token' =>
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  ),
);
$content['extra']  = array (
  'title' => '-5',
  'body_field' => '0',
  'revision_information' => '20',
  'comment_settings' => '30',
  'menu' => '-2',
  'path' => '30',
  'nodewords' => '10',
);

Thanks!

I have the same problem as igorik; as does another employee of mine. Has a solution been discovered?

MT

I have this problem too.
I have a required user reference field that is controlled by another field.
It doesn't matter what I do, if the field is visible (because the controlling checkbox is ticked) then when I try to submit the form it will complain that the user reference field is not filled.

Have encountered this problem too - is there a patch available to fix it yet?

Version:6.x-2.0-beta1» 6.x-2.0-beta2
Priority:Normal» Major
Status:Active» Needs review
StatusFileSize
new573 bytes

I ran into this issue, too. Here's a patch, and it's pretty non-controversial.

StatusFileSize
new567 bytes

Same story when working with email fields. This patch includes user reference correction.

I am experiencing the same problem with the Embedded Media Field module. I have enabled YouTube video uploads via Media: YouTube extension. Works flawlessly until I set a conditional field to trigger the Video field, and set the Video field to required. At that point no matter what I enter into the Video field it always throws a `Video field is required.' error on submit.

Are any patches available to address this issue?

StatusFileSize
new686 bytes

There is the same problem with the Role Reference module. I've included another patch to accommodate that module (in addition to the user reference and email field.) I'm starting to wonder if some other approach with this check should be done, like perhaps a hook that other modules could use to add their checks, or maybe a registry of ids they could add to that this could go through. Or perhaps an inventory of similar cck field modules could be done to see what else should be added to this growing list (like Block Reference or View Reference, because they too may be affected.

StatusFileSize
new696 bytes

Here is the same patch as above, but for the 6.x-1.1 version.

I've revisited this patch, addressing some of the issues I mentioned before. This patch now calls up a function that returns an array of id names - 'value' (normal field), 'nid' (Node reference), 'uid' (User reference), 'rid' (Role reference), and 'email' (email fields). That function actually invokes a hook to get the array values, so theoretically other modules could add their fields to that list (or people could write their own module to add the fields they need) and statically caches the list so the hook isn't called multiple times. This patch is for the now current 6.x-2.0 version.

#11 almost worked... thanks Matt-H! There was a missing closing parenthesis.
Verified that it fixes 6.x-2.0

No offense johnnydarkko, but are sure about that missing closing parenthesis?
patch-12 has:
+  if (!isset($ids) || $reset)) {
while patch-11 has:
+  if (!isset($ids) || $reset) {
It looks to me that patch-12 has an extra closing parenthesis. Am I missing something?

Title:CCK User reference module doesn't work if the field is mark as requiredRequired CCK User and Node reference fields cannot be submitted
Version:6.x-2.0-beta2» 6.x-2.x-dev
Status:Needs review» Needs work

I ran into the same problem, with a required Node reference field, using the latest 6.x-2.x-dev, which is 6.x-2.0+12-dev (2012-Aug-07). Patch #11 can't be applied anymore - could you please update it? Thanks!