Hello,

I'm using a Select (or other) with Conditional Field (Conditional Fields module). When the field is required and hidden, I need to enter a value in order to save the page. I can't make the field required...

With anoter cck field widget, I don't have this problem.

Comments

Junro’s picture

Title: Not working with Conditional Fields when this one is required » Not working with Conditional Fields when the field is required
haydeniv’s picture

Is this a problem with the Drupal 7 version of this module? I'm not actively supporting Drupal 6. If you need this for Drupal 6 patches are welcome.

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)
vivekguptakota’s picture

In D7, I am also facing same issue.

legolasbo’s picture

@vivekguptakota,

If this is an issue for you please re-open the issue and provide clear steps to reproduce on a vanilla Drupal installation.

jay-dee-ess’s picture

Version: 6.x-2.14 » 7.x-2.22
Component: CCK / Field API widget » Field widget (non-specific or listed)
Status: Closed (won't fix) » Active

Working w/ Webform 7.x-4.12

Steps to reproduce:

  1. Create select "Show Required Select" with options "On" and "Off"
  2. Create select "Required Select" with arbitrary # of options. Check "Allow Other Option"
  3. Add conditional: If "Show Required Select" is "On" then "Required Select" is required
  4. Submit form where "Show Required Select" is "On" and "Required Select" where an option is checked and Other is not checked.

Error:
Required Select Other (specify) field is required.

Note:
In the above scenario, if "Show Required Select" is "Off" and "Required Select" has a non-Other option checked, the form submits fine.

albertski’s picture

I'm having the same issue as well. Same thing as #6. If I don't use conditionals I don't run into any problems but if I do I get the issues.

The form error is coming from the webform_module in _webform_client_form_validate() on this statement:

      // Make sure a value is passed when the field is required.
      // A simple call to empty() will not cut it here as some fields, like
      // checkboxes, can return a valid value of '0'. Instead, check the
      // length if it's a string, and the item count if it's an array. For
      // radios, FALSE means that no value was submitted, so check that too.
      if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0) || $elements['#value'] === FALSE)) {
        form_error($elements, t('!name field is required.', array('!name' => $elements['#title'])));
      }

Noting that the select_or_other field is required. I'm assuming somehow during the conditionals it converts it to required.

capysara’s picture

I’m not sure if this is the same as (or just similar to). I’m using a regular node instead of Webform (I also tried it with an Entityform with the same results). If I make the select (or other) field conditionally required, then it throws an error even when something is selected.

Steps to reproduce:
drupal 7.59
download & enable these two modules
1. select_or_other-7.x-3.0-alpha2
2. field_conditional_state-7.x-1.1 (note: this is an older version. The newest version, 2.1, does not support the widget at all)

Manage fields - basic page
Add new list (integer) field with values (‘list’):
0|yes
1|no

Add new text field w/ Select (or other) list widget (‘other list’)
Default settings, except add Additional options:
1|1
2|2
3|3

Conditional State: “Field other list is required when field List has value yes”

Add content: /node/add/page
List: select yes
other list: select 1
Error message: ‘other list field is required.’

Thanks so much!

daften’s picture

Status: Active » Closed (outdated)

Closing as outdated because no activity in a long time and Drupal 7 goes EOL soon. Feel free to re-open if needed.