Closed (fixed)
Project:
Conditional Fields
Version:
8.x-1.x-dev
Component:
Compatibility w/ other modules
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Jun 2011 at 19:53 UTC
Updated:
4 Mar 2024 at 02:01 UTC
Jump to comment: Most recent
Comments
Comment #1
jackbravo commentedSub!
Comment #2
kenorb commentedFollow-up: #2143923: Postal Address (addressfield) is requiring Address 2 when the field is required
Comment #3
kenorb commentedComment #4
zmove commentedI reopen the issue because I have others problem with addressfield that the one related.
The problem is that you cannot define a field visibiliy depending on the the addressfield value (country for example).
Probably because addressfield is a set of field, conditional fields should probably have some custom code for that addressfield
Comment #5
kenorb commented@zmove:
You can use 'Regular expression' such as 'AT|BE|BG|HR|CY|CZ|DK|EE|FI|FR|DE|GR|HU|IE|IT|LV|LT|LU|MT|NL|PL|PT|RO|SK|SI|ES|SE' or whatever for Address field values match (containing Country values), but make sure that you set 'Custom jQuery selector for dependee' to select.country.
See also: http://drupal.stackexchange.com/questions/106457/how-to-add-a-conditiona...
Comment #6
redeight commentedI'm having a similar issue but it is sort of in reverse. If the dependant is the addressfield and the dependee something like a boolean, the addressfield displays even if I told it to hide unless the boolean is true. I'm not sure if it is related but the addressfield is inside of a Field Group Multiple.
Comment #7
davidczadilek commentedFor starters - what I'm trying to accomplish...
I have three fields - Select something for Country-X, Select something for Country-Y and Address (Country, Address 1, Address 2, Postal Code, City).
Depending on the Country select of the Address field, I want to show either the Country-X or Country-Y Select fields.
Also - there is several address fields used in this form (lets say e.g. billing and shipping).
@kenorb: you proposed just this solution - thank you for leading me in the right direction!
Altough some more problems occured - and for future refence to others, I'll go through step by step (not trying to use hooks):
Problem: Some of the address fields are by default required - meaning the parts address1, postal code, and city - probably depending on the country you select.
Now when adding the dependency as described, using the jquery selector and regular expressions, an error occurs that said fields are required.
Solution: To make this work withot having to add a hook - in the address field settings I checked Make all fields optional (Not recommended). Also I unchecked the required option on the address field itself in order to go through step-by-step.
Problem: The dependency still does not trigger right on the form, because multiple address fields are used in this case.
Solution: After inspecting the form and seeing that even the ID of the select field changes when changing the country, adding an id at the end.
I used a wildcard query to omit this
--#at the end, e.g.:select[id^=edit-YOURFORM-field-YOURFIELD]Problem: I still need the address field required.
Solution: I'm pretty sure theres a cleaner solution for this even without using hooks - e.g. using more dependencies - but who'd have known - I just set the requirements in the field settings again as desired - and it still works as desired without throwing any errors in the form.
Comment #8
mobius_time commentedI'm having the same problem as RedEight in comment #6, but my AddressField is not inside a Field Group Multiple.
When I create the node with the AddressField, it works on the node create page, but when I display the node it doesn't work.
Comment #12
dqdHas been committed for 8.x but forgotten to be set to "fixed". Apart from that:
Thanks for the report and all the efforts in here. But due to inactivity in this issue for some years and because of the upcoming EOL of Drupal 7, I will close this issue on the way by cleaning up the issue queue.
Feel free to re-open as "Needs review" if you found a solution or have a patch to be reported to help others on this outdated version.
If you think this issue or missing feature should be addressed in a newer Drupal core 8 and above compatible version of this project, then please file a new issue to the latest dev.
Comment #13
dqd