# Summary

Define dependencies between fields based on their states and values.

# Project URL

https://www.drupal.org/project/conditional_fields

# Where is the code?

8.x-1.0-alpha4

# Estimated completion date

Unknown

# Dependencies

N/A

# Who's doing the port?

https://www.drupal.org/u/olgarabodzei
https://www.drupal.org/adyax

# What help do they need?

Now we are actively working on the project and we would be glad to get any help (as developing, testing, reviewing).

# D8 roadmap

#2830988: [meta] 4.0.0 release roadmap

# Background and reference information

#2406265: Drupal 8 version Assigned to: OlgaRabodzei

Comments

Patrick Storey created an issue. See original summary.

peterpoe’s picture

Issue summary: View changes
mlncn’s picture

Differences with / chance for Unity in Drupal 8 for the https://www.drupal.org/project/field_conditional_state module?

OlgaRabodzei’s picture

I'm about to help to port the module.
Do You have any groundwork?
I would be very pleased if You could share it.

isimgt’s picture

OlgaRabodzei’s picture

Hi all!

I represent Adyax company. We started porting the module and finished some base work. We used ideas of conditional_fields and field_states_ui modules. And we would like to share our work. A DEV version could be provided by us in a week.

I would be very pleased if maintainers of conditional_fields module contacted me as soon as possible. I'll venture to update this task, this one (https://www.drupal.org/node/2406265) and Kanban board in a case you wouldn't contact me.

ion.macaria’s picture

Hello Olga, tell me please what is the progress with that module, and can you give me some code, or can I help you with something?
I have 3 years in drupal development, but I am beginner in drupa 8 (symfony).
I want to begin a project in drupal 8, and this module is vital for him.

OlgaRabodzei’s picture

Hello, Ion!
Sorry for a short delay. Here is a link to repository with the work we have done. In the master branch You can find working code, that uses conditional fields module's logic. And the field_states_ui branch contains an attempt to use plugin logic from field_states_ui module. I was inspired to try field_states_ui instead of conditional_fields by comments from the issue. Hope You'll find this code useful!

https://github.com/OlgaRabodzei/conditional_fields

itsekhmistro’s picture

Hi Olga,

Could you outline what features are currently working in conditional_fields port for D8 ?

Thank you in advance.

OlgaRabodzei’s picture

For now code provides:
1) Add/edit/delete conditions operations. All settings are saved in an entity form display configuration.
2) Working conditions are "is filled" and "is empty"
3) Working states are:
- visible
- invisible
- required
- optional
4) Also validation works properly

RKopacz’s picture

I just tested the module from the git repo in #8, as I have an immediate use case. After installation, neither the manage form display page nor the manage display tabs resolved when I clicked. I received a "Can't display site" message in Chrome. The following message appeared in Watchdog:

nvalidArgumentException: EntityDisplay entities can only handle fieldable entity types. in Drupal\Core\Entity\EntityDisplayBase->__construct() (line 126 of /var/www/wildlife/core/lib/Drupal/Core/Entity/EntityDisplayBase.php).

OlgaRabodzei’s picture

Hello, Robert!
Some bugs were fixed.
I would be very pleased, if You tested the module one more time.

lathan’s picture

Module tested https://github.com/OlgaRabodzei/conditional_fields

I added the module then I have been trying to add the very first dependency we have. Where the label field on a blog entity type is dependent on a value “Employee Benifits” in a term reference field. It would also not save the value field no matter what I entered.

It does not want to hide the label at any point when I create a new blog post. Even if I say only show the label field if the field is filled…. still no hiding.

On a side note even once you have added a conditional field. "/admin/content/conditional_field" does not list the current fields, you have to re-traverse the relationship tree before you find what you added before.

Best lathan

RKopacz’s picture

Thanks, @OlgaRabodzei I'll test it shortly.

OlgaRabodzei’s picture

Hello everyone!
I kindly ask all not indifferent to join the discussion on Friday!
Let it be at 15:00(CET) on Friday 21/10/2016.
The goal of it is to discuss the future of next three projects that solve one issue and to make one general resolution for it.
The projects are
- https://www.drupal.org/project/conditional_fields
- https://www.drupal.org/project/field_states_ui
- https://github.com/OlgaRabodzei/conditional_fields

You could ping me on the email (orabodzei@adyax.com) for sending an invitation.
Also I'll provide here a link an hour before we'll start.

OlgaRabodzei’s picture

Assigned: Unassigned » OlgaRabodzei
Issue summary: View changes

Hello!
As I didn't get any response from maintainers, I ventured to create the task https://www.drupal.org/node/2827031
Also I decided to assign to me tasks related to Drupal 8 version of this module.

OlgaRabodzei’s picture

Status: Active » Needs work

Hello!
The dev-version that we made was published on drupal.org

juliencarnot’s picture

Hi Olga,

Are you going to create dev release on drupal.org? Might help testers to give it a try.

Should I copy the pending issues from GitHub to here so that we can focus on this queue?

Thanks again!

maxilein’s picture

Please, a dev release!

Anonymous’s picture

@Olga, are you sure? The only d8 version I see has been added on 29-9-2015.

juliencarnot’s picture

@Vic: there's no dev release yet so you won't see it on the project page, but the latest code has been commited: http://cgit.drupalcode.org/conditional_fields/commit/?id=25c2d427b791dd5...

you can git clone git://git.drupal.org/project/conditional_fields.git and git checkout 8.x-1.x to test it.

OlgaRabodzei’s picture

Status: Needs work » Needs review

Hi all!
I added dev release, but it's not stable yet.

@Julien, I would be very pleased, if You found time to copy tasks from GitHub.

KevinVb’s picture

Installing the dev version gives:Error: syntax error, unexpected '?' in modules/contrib/conditional_fields/src/Form/ConditionalFieldEditForm.php,
line 190

First testcase:
Also hide/show isn't working for radio buttons. The element is hidden but never shown.

Second testcase:
I wanted to try to show/hide a field when a email field isn't empty. So i used the email value with the setting 'Filled'.
But then I can't save the condition:
Javascript error: An invalid form control with name='field_email[0][value]' is not focusable.

We are looking for a state module for fields. So maybe we will be working on this module.
It depends on the maintenance of this module.

itsekhmistro’s picture

Hi Kevin,

Thank you for review but please avoid using this issue for posting bugs. It's a major issue for tracking D8 port status.

I will appreciate if you follow Drupal org approach: First check if there is already a known issue and if not create a new one.

Just in case.
>Installing the dev version gives:Error: syntax error, unexpected '?' in modules/contrib/conditional_fields/src/Form/ConditionalFieldEditForm.php,
line 190

Already fixed.
For other testcases please create an issue if doesn't exist yet.

Regards.

zerolab’s picture

Issue summary: View changes
geek-merlin’s picture

Crosslinking #2851763: [ddf] Dynamic dependent fields, which has similar and imho non-overlapping use cases.

EDIT: What if we extend StateAPI with an operation like "ajax-reload the target field" and condition "field has changed"?
This would leverage the Framework to obsolete the other module.
Ore are they too different in the end?

(Hmm, as i see, ddf maintainer @maximpodorov also is at adyax...)

shaisamuel’s picture

Any timeline or estimates for first Alpha version?

Rus71Kolosvetov’s picture

EntityReference get always node(Node::load), not view on "#target_type" but "#target_type" may be not node, example "taxonomy_term" and module work wrong

mmjvb’s picture

Status: Needs review » Needs work

Set Status to Needs work because there is only a dev release.
For Needs review it needs a tag for alpha or beta.
When the work is more like an RC, it should be tagged as such and Status set to RTBC.

focus13’s picture

Title: [conditional_fields] Conditional Fields » [views_exclude_previous] views exclude previous
Issue summary: View changes

Revert changes.

focus13’s picture

focus13’s picture

Issue summary: View changes
focus13’s picture

Issue summary: View changes
focus13’s picture

Issue summary: View changes
focus13’s picture

Issue summary: View changes
mmjvb’s picture

@focus13 Please undo your changes. This issue is about conditional_fields, create a new issue for views_exclude_previous, if you need one!
Don't change the title of an issue here, unless it is incorrect.

focus13’s picture

Title: [views_exclude_previous] views exclude previous » [conditional_fields] Conditional Fields
Issue summary: View changes
focus13’s picture

Issue summary: View changes
focus13’s picture

@mmjvb forgive me, i revert all my changes. i hope all things are corrects now ?

mmjvb’s picture

@focus13 don't worry, we all make mistakes. Noticed that you are still assigned. That lead to checking the differences. Use the View history link at the top, check the issue with my change and compare it with the current one. There shouldn't be any difference.

Saw you created a new issue for views_exclude_previous, thumbs up!

OlgaRabodzei’s picture

Assigned: focus13 » OlgaRabodzei
jhego’s picture

The module no longer works since the update to the alpha version, please fix that

mmjvb’s picture

@jhego For support create an issue with the project itself.

OlgaRabodzei’s picture

Status: Needs work » Needs review

Julien, please, check alpha2 release. If You have any troubles with the module, please, check this list first and than create an issue.

mmjvb’s picture

colan’s picture

@OlgaRabodzei or any other maintainer: I just spent some time sifting through the issue queue reviewing patches and such, setting some RTBC issues to Needs Work and whatnot. There are now 7 RTBCs that look good.

Would you kindly commit these, or if you're too busy, I'd be happy to help with co-maintenance (committing patches and cutting releases) if you'd be willing to grant me maintainer access. Thanks!

colan’s picture

Issue summary: View changes

Will be working on this now that I have access as per #2925603: Offering to co-maintain Conditional Fields. Note that I added the roadmap issue here.

mmjvb’s picture

Issue summary: View changes
colan’s picture

Issue summary: View changes

Just released 8.x-1.0-alpha4. There's still a fair amount of work to do so help would be really appreciated. Take a look at the #2830988: [meta] 4.0.0 release roadmap to see what's left.

Also note the discussion in #2913096: Business Rules module's "Dependent fields" feature: overlap discussion.

Leagnus’s picture

8.x-1.0-alpha4 doesn't work with commerce-8.x-2.x-dev product types fields.

colan’s picture

#50: Please open a separate issue for that if there isn't one already. Thanks!

mmjvb’s picture

Issue summary: View changes
dqd’s picture

colan’s picture

#53: That place for that discussion is #2830988: [meta] 4.0.0 release roadmap. Please add your comments over there.

dqd’s picture

#54: Agreed, and I actually know ... *urg* - mixed browser issue tabs here... Sry and Thanks for informing me. https://www.drupal.org/project/conditional_fields/issues/2830988#comment...

geek-merlin’s picture

I have put quite some work into making this work for D8, but at some point i saw that server side form structure and client side HTML structure are such a mismatch that abstracting JS StateApi like this will take huge amounts of effort to maintain and track changes in widget structure.

I'm currently working on Ajax Dependency which does the dependencies server-side. If someone wants to merge this into conditional_fields (making StateApi and AjaxDependency dependency provider plugins), i am very willing to support, and can help with that.