Closed (fixed)
Project:
Date
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2011 at 07:37 UTC
Updated:
14 Apr 2014 at 16:30 UTC
Jump to comment: Most recent
I tried to hide a date_popup field using the drupal #states but I wasn't able to make any date_popup item invisible. It works fine with default drupal field types.
Comments
Comment #1
thomas4019 commentedI had this same problem too. I worked around it by wrapping the date_popup field within a fieldset.
Comment #2
arlinsandbulte commentedDate 7.x-1.x is unsupported.
This issue should be verified in the latest version of Date (7.x-2.x-dev) and re-opened if still valid.
Thanks
Comment #3
jonlhouse commentedI'm experiences similar problems with #states not working even after installing date-7.x-2.x-dev. My code looks something like:
Basically if the user selects to choose their own date range (value: 'user_dates') the date_popup widget should appear. I included code for the select dropdown because the #states property functions properly with that widget. I didn't use the standard ":input[name=FORM_NAME]" since I've never gotten that to work properly so I assign a id instead and explicitly label the input.
Hope this helps. Thanks.
Comment #4
jesss commentedI have updated to 7.x.-2.x-dev and can confirm that #states does not appear to work with the date_popup field type -- or any of the other widgets.
I'm trying to use Date in conjunction with the Conditional Fields module, which controls the visibility of fields using the States API. The desired outcome is that when the event type is "repeat," this date field should be visible. (Note: This works as expected when switching a regular text field visible/invisible -- it's when the visible/invisible field is a date field that it breaks.)
When the form is rendered, the #states information is part of the form array, but it is not honored. Here's the output of the date field:
Comment #5
slashrsm commentedI experienced the same error with form types.
Comment #6
karens commentedI think the issue is that the date module creates a collection of fields instead of a single field. I am adding a wrapper around the collection to mimic what other fields look like and using states in some new code I will be adding to allow the user to hide/show the end date.
This will be committed shortly.
Comment #8
ifux commentedSorry to reopen, but #states is still not working with date_popup field type.
visible and invisible works BUT for example enabled and disabled is not working!!!
Any ideas/help to fix or work around???
Thx
ifux
Comment #9
karens commentedPlease don't reopen a closed issue with a vague 'doesn't work' comment. You should provide a detailed description of what you tried that did not work. If you tried to apply 'disabled' at the top level of a collection of date fields, it will not work. That has nothing to do with #states, it won't work no matter how you do it, you can't disable a collection of fields. #disabled has to be applied to each individual form element to do anything. If that's the only issue here, this has nothing to do with #states and the issue is still fixed.
Comment #11
liquidcms commentedwon't re-open.. but i'll add my example usage in case anyone was like me and wasted a couple hours trying to figure this out.
i programmatically created an instance of a date_popup field for a custom node type in a custom module (i think things like datepicker_options and states should be definable when instance is being created; but couldnt figure that out so i did it with a form alter)
in my form alter i added this:
where 'reservation_repeat_type' is a radio buttons field. the part i missed was adding the [und] in to the states field selector.. and likely should be a 3rd level of quotes around the und i.e. ['und'] but i left it out and it worked.. but not good php practice.