Download & Extend

Reset controlled fields to default values if untriggered

Project:Conditional Fields
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

When submitting something based on two options say "free and premium" from the allowed values list, if premium is to show "website" field and you type in the url and then change it to free, the website url will still be submitted. Is it possible to reset/empty the field when it toggles to different selection?

Comments

#1

I see two questions here:
1. Should data from an inactive controlled field be submitted?
2. Should data from an inactive controlled field be retained for user convenience in case that field is activated again. (i.e., it goes from visible to hidden and back to visible again.)

Currently, conditional_fields answers these questions as (1) Yes, (2) Yes. Instead I think the answers to these questions should be (1) No, (2) Yes.

Rationale for (1) No:
- In most common use cases for conditional_fields, user would not expect non-visible controlled-field data to be submitted. (This is true for my sites.)
- The fact that a required controlled field is not required when it is inactive implies that conditional fields are both presentationally and logically conditional. Since conditional fields are logically conditional, they should not have any effect when inactive, and their data should not be submitted. In other words, we don't care whether a field is required when it is inactive, so we shouldn't care what the contents of that field are either.

Rationale for (2) Yes:
- User does not lose what they typed in if they change their mind and decide to re-activate an inactive controlled field.

Therefore, I propose we change the module so data in an inactive (hidden) controlled field is not submitted. I also think that if possible, data should be kept/buffered when a controlled field is hidden in case the user decides to unhide it.

#2

Version:5.x-1.x-dev» 5.x-2.x-dev

#3

Version:5.x-2.x-dev» 5.x-1.x-dev

whoops, changing back

#4

threxk,

I think you're right. At least the behaviour you described should be the default.

#5

I have a related question or may be feature request?
Here it is:
I need such logic:
1) have field with some options, for example 0|restaurant, 1|chef
2) when is choosen "restaurant" we see several fields specific to restaurants and some of them are required
3) when is choosen "chef" we see several fields specific to chefs and some of them are required
4) if user filled fields for "restaurant" and after choosed "chef" and then back to "restaurant" fields about restaurant stay filled
5) when the form is submitted if the last time it was choosen "restaurant" then only fields for restaurant are written to database but fields for "chef" are not even if there were required fields.
6) the required fields for "restarant" if it was choosen the last time must be filled or the form is not validated.
7) the required fields for "chef" if it was choosen the last time must be filled or the form is not validated.

Is it possible to do with this module(drupal-6)?

Thanks!

#6

Title:Reset when changing between conditional field list» Reset controlled fields to default values if untriggered
Version:5.x-1.x-dev» 6.x-1.x-dev
Status:active» needs review
AttachmentSize
conditional_fields_reset_defaults.patch 5.7 KB

#7

Thanks, peterpoe, is this feature allready in last 6x-beta version of the module?

#8

@netbear Yep!

#9

This patch seems only works for drupal 6, is it possible to have a patch for drupal 5?
Thanks,

#10

Status:needs review» needs work

This patch is creating error messages for people who are updating to the 6x-beta from earlier versions. See #373899: warning: Invalid argument supplied for foreach() The problem appears to be in the way you are selecting the default value. It does not work for some field types.

#11

hi
I am facing at the moment one problem which is nothing to report an error in module but adding more functionality.
for example:
Its a registration form for the models of all ages. form works fine if some one first select the gender and then select the age group, forms hide and show in the right way but if someone select first the age group and then gender then forms doesn't work the way it should.

For example in my registration I don't wont people belongs to age group 0-13 need to fill their shoe size, bra size etc but I do want people from other age groups need to fill. I think its bit complex to explain in words. I would like to take some and ask you to visit the following link to understand my issue. before you go to the link I would like you to do few things on the registration form to save your time.

1. Select Model Registration from the Registraion Type
2. Select 0-13 from the Age Group
3. Select Female from the Gender

(you will notice all sizes i.e. shoes and bra etc. form become visible which i don't want.)

1. Select Model Registration from the Registration Type
2. Select Female from the Gender
3. Select 0-13 from the Age Group

(you will notice all sizes i.e. shoes and bra etc. forms become hidden which i do want.)

Link: http://www.milajula.com/gmm2/user/register

is there any way to achieve my goal. I hope you understand my problem
Thanks in advance
Regards
Kaay

#12

Sorry my mistake. I should have posted this as a new thread.

#13

The problem still persist for the latest release after the patch....
Any idea?

Thanks,

#14

Status:needs work» closed (duplicate)

Duplicate of #475884: warning: Invalid argument supplied for foreach() in conditional_fields.module on line 709..

#11: Looks like your problem is that you're trying to set multiple controlling fields for the same controlled field, which is not yet supported by conditional fields. This feature will be added after release 1.0

#15

Status:closed (duplicate)» closed (fixed)

#16

For those looking for a solution and for those contemplating how to build it out, some consideration may give given to the Rules module and how it can solve problems. In my case, I had a controlling field to show/hide a Link field and FileField.

The case and solution are here:
http://drupal.org/node/596612