Hi,

I have a conditional, required field which is rejected even when it is submitted complete. By rejected, I mean that the node edit form returns error "field x is required" even when it was complete upon submission.

I have checked and can confirm that when I remove the condition from the required field in question, it behaves properly (Errors when left empty, saves when submitted complete)

I am using Drupal Core 6.25 with Conditional Fields version 6.x-2.0
Please let me know if you need more information, Thanks in advance!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Version: 6.x-2.0 » 7.x-3.x-dev

I have the same problem on Drupal 7. It won't accept the form.

goldtopdon’s picture

Version: 7.x-3.x-dev » 6.x-2.0
Component: Miscellaneous » Code

Hi,

The patch supplied in #11 here fixed my problem, may help others too:
http://drupal.org/node/722236

Regards,
Dan

yvmarques’s picture

I had the same problem and I could fix it with the attached patch.

To be honest I haven't tried with other modules than just CCK, might need some reviews.

areynolds’s picture

Version: 6.x-2.0 » 6.x-2.x-dev
Status: Active » Needs review
FileSize
1.37 KB

Reviewed the patch in #3; the removed code was causing the error in my case, but so was the following block:

  // Last resort: maybe the field uses a generic "value" key.
  if (is_null($value) && isset($item[0]['value'])) {
    $value = $item[0]['value'];
  }
  else {
    // if no value was found, assume that the field is empty,
    // which may be annoying, but prevents saving incomplete data.
    return true;
  }

This block occurs after $value may have been defined by preceding code. If a legitimate, non-null $value exists, the "else" clause will mean that it is always ignored and the field is regarded as empty. Deleting the else clause causes no harm; if $value is empty (a null value), this will be caught by the final logic check:

  return !count($value) || (is_string($value) && drupal_strlen(trim($value)) == 0);

Attached patch builds off of #3 and deletes the else clause. I'm wary of getting rid of the block deleted by patch #3, but I'm not familiar with hook_content_is_empty, so perhaps others can advise?

Note that this patch applies against 6.x-2.x-dev.

alibama’s picture

Confirm patch #4 fixed us using the latest dev version = thanks areynolds et al

yvmarques’s picture

As I understood, the hook_content_is_empty doesn't check if the content is empty but set the default empty value to the field.

areynolds’s picture

So it's a function that allows you to designate custom "empty" functions on a field-by-field basis? If this is the case, we should debug that code block removed in #3.

Danny Englander’s picture

I ran up against this same issue today and the patch in #4 worked to fix a conditionally required text field but not for a conditionally required imagefield image. In other words on the same node I have both and the textfield works as expected now but I still get an error on node save that the image is required even after I've checked off to allow for an image and uploaded an image. I don't know enough of the nuances here to figure out why.

Danny Englander’s picture

Issue summary: View changes

Added details of my Drupal and CF version

peterpoe’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)