question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PRO-1512 Conditional fields inconsistencies

See original GitHub issue

Describe the bug

  1. A conditional field can not be required. If it is required, page/piece can not be saved. It makes sense both UI and API to ignore completely a conditional field which is not meeting a condition. If this is the behavior by design, please ignore this.
  2. If conditional field is prefilled it is not nullified when it doesn’t meet the condition. Its value is still sent by the UI to the API. I could agree it’s a developer reposibility to nullify the value in post create/update event handler, but there should be a clear instructions about that. So again, is it the desired behavior?
  3. Related somewhat to 2., if there is a default value for a conditional field, it is saved to the DB no matter the condition for this field is not met.

To Reproduce

fields: {
  add: {
    category: {
      type: 'select',
      label: 'Type',
      choices: [
        {
          label: 'Cat 1',
          value: 'cat1'
        },
        {
          label: 'Cat 2',
          value: 'cat2'
        }
      ],
      required: true
    },
    conditional: {
      type: 'string',
      label: 'Conditional field',
      if: {
        category: 'cat1'
      },
      required: true
    }
  }
}

For 1. try to submit while selecting Cat 2 For 2. set the required: false flag, choose Cat 1, fill the Conditional field, choose Cat 2 and submit. You should see the value you’ve filled is saved to the database For 3. add def: 'Default' to conditional and def: 'cat2' to category field scheme, create new piece item without changing any fields. Value Default is saved to the DB for field conditional.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
abeacommented, Jun 21, 2021

It looks like there was a misunderstanding here. I think @myovchev was saying that currently a required conditional field will throw an error even when it is hidden. I’m finding that as well. That should not happen. I think we should also reconsider the other points. I’m not finding documentation of the decision on that point.

I’m reopening to address the first point at least.

0reactions
abeacommented, Dec 1, 2021

closed by #3437

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues for Conditional Fields | Drupal.org
Title Status Priority Cate... Automated Drupal 10 compatibility fixes Needs work Normal Task It doesn't work on entity reference field. Active Normal Bug r... Checkboxes broken...
Read more >
Understanding Conditional Field Logic - iCIMS
Through Conditional Field Logic, user admins can control which profile fields are displayed—and which options are listed for those fields—based on how other ......
Read more >
Creating conditional fields on a form - ServiceNow Community
Solved: When an incident is Prio1 or Prio2, there must be a Incident Report attached when changing State to Resolved. 1 How to...
Read more >
Conditional fields don't work - WordPress.org
I just ran into issues with conditional fields. ... Also, check site health section under tools tab in admin dashboard and search for...
Read more >
NetSuite - Using Conditional Fields with Actions
Cloud · Cloud Applications · NetSuite. NetSuite Applications Suite. Table of Contents; Search. Contents. Expand AllCollapse All.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found