- Issue created by @coreteamvn
- π©πͺGermany jurgenhaas Gottmadingen
This one is really difficult to provide support for. It is not exactly clear what this means:
multi-value nested fields (from the double field or datafield modules)
Multi-value field seems to be clear, but "nested" is confusing. Also "double field" could either be a field type containing doubles, i.e. numbers with a decimal. But I guess it means more like a field type that contains multiple properties? And last but not least, I'm not sure what you mean by "datafield modules".
To be helpful in some way, it would be important to get a simple working example, where we can try to reproduce and maybe fix the issue. For that, the most simple model that lets you reproduce the problem should be uploaded. That may require some extra modules or even some custom code which defines the field type. If so, please upload that as well. Then we can have a look.
- π¦πΉAustria coreteamvn
Hi JΓΌrgen!
Sorry for not being clear enough.
Nested: The doublefield β module and datafield β modules provide for a composite structure. Ive been using double field with d9 and it works very well and is a stable module (also has good views integration).
The modules allow two (double field) or more (datafield) values (text, int, decimal, entity reference,...) to be stored in one field. For instance, one can store a name and some score in one field. In that sense it is similar to the above mentioned thread where one can use YAML to set a structure like:
0:
first: "name of player"
second: 12I cannot get this to work. Ive been trying the datafield and doublefield module and the result is the same. I can only set the values seperatly in two actions (first and second) where i target a specific delta, but not in one action. Setting value separatly is fine when one can target/set a specific delta (this works perfectly already), but when one wants to add a double field, this approach does not work.
Attached find a simple model and a screenshot of the properties of the node and the double field in particular. It requires the installation of a double field module (e.g. text and decimal as first and second subfield) attached to a content type. When one updates node 287, node 286 with the double field is loaded and two new values should be added. however, the actions (before) getField value are not executed and a few checkpoint display messages are not firing. From the error log:
Failed execution of getValue (Activity_0ir16h6) from ECA Testing DoubleField Additions (process_dbpnxw7) for event Drupal\eca_content\Event\ContentEntityUpdate: Property value is unknown Failed execution of getDelta0 (Activity_1suu54n) from ECA Testing DoubleField Additions (process_dbpnxw7) for event Drupal\eca_content\Event\ContentEntityUpdate: Property value is unknown
I hope this is useful for you. Please let me know if you need something else.
- π©πͺGermany jurgenhaas Gottmadingen
Looks like this is a bug in the double_field module. Their field type defines 2 properties:
first
andsecond
. But they don't define the name of the main property which results invalue
being used as the default. That said, Drupal now checks on the propertyvalue
which doesn't exist and hence the ECA model has no access to write to that field.The solution is simple: double field needs to implement the following method into their
\Drupal\double_field\Plugin\Field\FieldType\DoubleField
class:public static function mainPropertyName() { return 'first'; }
Then it works just as expected.
However, the model would still not work, because the field value needs to be yaml and it needs to be using the correct property names. I've build another test model for this, which I think is really a simple one and looks like this:
The model is attached.
Please report the bug to the double_field issue queue - and maybe also to the datafield issue queue as they may have the same issue.
- π¦πΉAustria coreteamvn
Thanks for the info!
I have posted your suggestion in their forum and added the static function in double field FieldType file.
Getting values and display them work now, but the problem with setting/appending is that it creates a new row for each entry. Rather then appending one row with "player" and "points", it adds two rows: one row with "player value" and empty "points" and one with empty "player" and with "points" value. See attached emptyRow screenshot. I have set "save entity" to "no" in the setField action and added a separate "save action" for the entity. The result is unfortunately the same.
The only way i could append entries was counting the existing delta and set and clear this delta directly (see above). however, this approach essentially crashed the drupal installation (the error log showed attempts to set/add field values even after deleting the model). Im not sure if there was another update node model running that actually caused this.
- π©πͺGermany jurgenhaas Gottmadingen
Oh, I see. Yes, it really adds two rows instead of adding one row with 2 values.
I've just checked the code and have to confirm, this is how it currently works and there is no quick fix to that, I'm afraid.
Maybe you could resolve it like this:
- Append a new row with just the player name
- Then get the index of the last row
- Set the property for the second value as
field_stats_com.#.second
and save the entity
That's probably the best you can currently do.
- π¦πΉAustria coreteamvn
Thanks for the info, JΓΌrgen!
Will do it like that.
- Status changed to Closed: works as designed
almost 2 years ago 9:35am 9 February 2023 - π¦πΉAustria coreteamvn
update regarding double_field π Workflow/ECA Module: Definition main property missing Fixed :
Added mainPropertyName method that returns NULL as documentation suggests.