PRO-1512 Conditional fields inconsistencies
See original GitHub issueDescribe the bug
- 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.
- 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?
- 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:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
closed by #3437