Compatibilty with date module

threexk - June 9, 2008 - 18:28
Project:Conditional Fields
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

Date module select lists and text fields are required even if they are hidden (their controlling value is not selected).

I believe the problem stems from how a Date field is specified as required:

Results of print_r($form['field_birthdate']):

Array
(
    [#tree] => 1
    [#weight] => 0
    [#validate] => Array
        (
            [date_widget_validate] => Array
                (
                )

        )

    [0] => Array
        (
            [#type] => date_combo
            [#field] => Array
                (
                    [field_name] => field_birth_date
                    [type] => date
                    [required] => 1
...snip...

With this there are two issues:

  1. Conditional Fields looks for '#required', but not 'required'
  2. Conditional Fields uses element_children() and so does not look at #field property children.

Should the Date module should change to represent required in a normal way? Or should Conditional Fields accommodate the Date module?

#1

threexk - June 9, 2008 - 20:08

After further research, the Date module does use the #required property for all its form elements. However, it is done by a #process function, which is called after hook_form_alter() where Conditional Fields looks for #required.

At the hook_form_alter() stage when Conditional Fields runs, a date field is sort of a super field that can consist of multiple normal fields; at the #process stage it expands the super field into all its constituent fields.

I found this diagram really helpful for visualizing the sequence: http://drupal.org/node/165104

I am now wondering if Conditional Fields's hook_form_alter() code should instead be executed at the #afterbuild stage, so it deals with the final, processed form (hook_form_alter() could register a #afterbuild callback.) Will need to think about it more...

#2

threexk - January 10, 2009 - 17:16

I hereby offer a $5 bounty to anyone who can fix this issue within two months. Payment would be via PayPal.

The money probably is not commensurate with the work, but perhaps it will provide some extra motivation to someone who was already thinking about fixing it.

#3

peterpoe - January 24, 2009 - 14:45
Status:active» postponed

Postponing all compatibility with non-core cck modules to future releases.

#4

opensanta - May 25, 2009 - 19:04
Version:5.x-1.x-dev» 6.x-1.x-dev
Status:postponed» postponed (maintainer needs more info)

Please try the latest releases of both modules and update this issue.

#5

peterpoe - June 9, 2009 - 16:38
Title:Date module fields required even if hidden» Compatibilty with date module
Category:bug report» feature request
Status:postponed (maintainer needs more info)» postponed

Please report here any incompatibility with date module.
Please note that work on compatibility issues with non-core cck modules is postponed after the release of Conditional Fields 1.0 (but patches are welcome of course).

#6

GuyPaddock - June 27, 2009 - 04:38

I'm still seeing this behavior with the Date and Location modules. Both field types have nested fields with their own #required attributes, but conditional_fields_node_editing_form doesn't seem to recurse.

I should note that the date and location fields are being used within field groups, and it is the field group that has the conditional field setting (i.e. when another field has the right value, the field group becomes visible).

#7

akolahi - September 7, 2009 - 08:01

Using Conditional Fields 6.1-dev (Aug 15 2009) and Date 6-2.3 Initial testing is showing that i am able to set a date field as a conditional field that is properly triggered. I tried saving the field triggered and not triggered and so far is appearing to work properly.

Will test further and will report of any strange behavior.

#8

akolahi - September 7, 2009 - 08:32

If the Date field is required I am getting an error message saying the date field is required even though the date field is not triggered and thus is unavailable.

If the date field is not required then it looks like it is working properly - at least thus far in my testing...

#9

akolahi - September 7, 2009 - 08:40

I'm willing to make a financial contribution to getting the this issue fixed and the date module compatible with conditional fields. Let me know if your interested.

 
 

Drupal is a registered trademark of Dries Buytaert.