Is there anyone who succesfully assign values to double field's fields? If I try to assign a double field value(as it is, double) to another double field(as double) it works. However when I try to assign some custom values to each of the fields of an double field Im getting "Unable to set the data property first as the parent data structure is not set" error message.

Im using the "Set a data value" option from the Rules action menu. Im able to reach to each individual fields as "first" and "second". I tried straight order, as well as the reverse order, for assigning the values. Changed the required options on and off but it doesnt work. Im always getting that parent data structure error message.

Is there specific way to do that? I dont know if this is a bug or a missing feature or I just need to follow a special way to make it work but I believe this is very important.

Thanks...

CommentFileSizeAuthor
#4 second-subfield.png8.86 KBChi
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chi’s picture

Priority: Major » Normal

I have tried to assign custom values to subfields. It works well.

hgurol’s picture

There is something wrong here.
Can you please try this.

Add a new field to the Basic Page content type as follows.
Label: weight
Data Type: Double field
Widget: Text field & Select list
On the settings page I only edit the allowed values list for the second subfield - select. "gr" and "kg" are my only allowed values for this field. All other settings are the defaults.

Now please create the related rule.
Action on event: After saving new content
Conditions: Node > Content is a type of > Basic Page
Actions: Set a Data Value > node:field-weight:first > value is 999
optionally you can add another action for the second sub-field.
Actions: Set a Data Value > node:field-weight:second > value is kg

Now create a Basic Page content type and leave the double field fields empty. The rules doesnt assign the values to the double field and the error message in the Rules log is "Unable to set the data property first as the parent data structure is not set."

hgurol’s picture

Now I have just noticed that, if the double field has some data, then the rules is able to assign the required values. Like the example above, if you post 12 gr on the form submission, rules is working and makes the data 999 kb. Is just does not work when the fields are empty and there is no selection on the select list.

Im not sure if this is a problem with the rules module. Because when I try the same thing with a regular text field or with a select list field type, it just works in either case. It doesnt work when the Double field is used.

Chi’s picture

Project: Double Field » Entity API
Version: 7.x-2.0-rc1 » 7.x-1.x-dev
Component: Code » Code - misc
FileSize
8.86 KB

This works well if you set default value for second subfield.
Rules integration is done by using the Entity API. So I believe it's more appropriate place for this issue.

hgurol’s picture

@Chi
Yeah, I just noticed that it works whenever there is a default value in the second sub-field but that requires me to make the first sub-field not required so it can be posted empty to make my rules kick in. And it somewhat kills my whole workflow.

Are you sure that this issue is more related with the Entity module?

hgurol’s picture

Project: Entity API » Rules
Version: 7.x-1.x-dev » 7.x-2.1
Component: Code - misc » Module Integrations
Category: support » bug

I have found this issue related to this problem #1431952: Date field will only set in Rules if it already has a value

Its says they can not assign values to a date field through rules if the "collect an end date" option is checked. But it works otherwise.

Its just the same with Double Field module. I can set values to a double field as double, from a different double field. It does not work when I try to set a data value to the first or second sub-field within the double field. I tried both the stable releases and dev versions of Rules & Entity modules and the problem is still there.

Im not sure if this is a bug within the Rules module but its better if fago takes a look at this and then we can move this into a more appropriate place.

Thanks...

Chi’s picture

Yep, Date module got the same problem.

hgurol’s picture

Version: 7.x-2.1 » 7.x-2.2

Same problem is still there with the new version 2.2

maxplus’s picture

Hi,

I have the same problem using:
Date - 7.x-2.6
Rules - 7.x-2.2

I have not found a workaround for this, even when trying to use a single date without a end date.
I hope there will come a solution in het next release of the Date or Rules module...