I've got some forms that need to use Field Collections. I want to add up the values in some fields in said Field Collection table.

If I just put something like sqrt(25) in the default value, it will render the value once the form is saved as a draft or actually saved.

However, any time I use a token for a Field Collection item, nothing is rendered. Let's say the field is named "field_a_1". I go and put a value in the form field, save the form, and nothing. I've tried the following token formats: [field_a_1], [field_a_1:value], [field_collection_item:field_a_1], and [field_collection_item:field-a-1].

Am I missing something or does this module not allow the its usage in a Field Collection?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

HunterElliott created an issue. See original summary.

draenen’s picture

Title: Field Collection fields don't seem to be recognized » Support the Field Collection module
Version: 7.x-1.0 » 7.x-1.x-dev
Category: Bug report » Feature request

Math Field doesn't currently support field collections. Could be a very handy feature though.

HunterElliott’s picture

Yes, it certainly would! Thanks for the answer.

dela.deyoungster’s picture

Thanks for all your hard work @draenen. Will be really looking forward to this feature.

Sandip Choudhury’s picture

Yes, this Feature is absolutely necessary.

puudutus’s picture

Hi,

I'm wondering how much work would it be to get mathfield to work with Field Collections? As it stands, it almost works.
If after saving the the node with I a field collection field, I click edit on the field collection itself, the value is calculated correctly.

1. Create a node with a field collection field
2. Now the math field is still empty
3 Click edit on the field collection field itself
4. Here the math field works as expected. Also when the field edit form is saved the math field calculates correctly.

W.M.’s picture

Any progress?

Yuri’s picture

Plus one!

IKE0088’s picture

plus one

NWOM’s picture

There is a "follow" button in the upper right hand corner, which allows you to follow the thread without sending an e-mail or notification to every user in the thread. Just for future reference :)

nerdstein’s picture

Assigned: Unassigned » nerdstein

I'm working on this and have a patch almost ready

nerdstein’s picture

This patch moves this effort forward. It also now supports cardinality.

It is a work in progress -- I'm seeing some warnings and notices and I recognize it needs extensive testing.

I would also consider making a new major version, since I am proposing an API change.

HunterElliott’s picture

I've tried this with the patch inside a Field Collection item and it does seem to work, but I'm seeing an odd thing re: the read-only field display.

If I use a read-only math field in a *regular* entityform form, the field label and value are hidden until the form is submitted. This does work as expected.

However in the Field Collection item, I have placed the read-only mathfield at the end of the Field Collection item, but the field label and value are appearing at the TOP of the unsubmitted form. This should not appear at all in an unsubmitted form (like it does when placed in a regular form/entityform). When you submit the form with the Field Collection item, the mathfield in question does appear in its proper placement within the form and does do the sum properly.

Travis Kroh’s picture

This would be an excellent time to consider compatibility with the Paragraphs module, too, since the Field Collection page itself declares that "Field collection is on its way to being deprecated. It is recommended to use paragraphs instead...."

mastoll’s picture

Math Field is not YET compatible with Paragraphs, right?

Edit: @NWOM, you are spot on. This question belongs in a different issue. I reacted to @Travis Kroh's post above without thinking it through. Sorry!

NWOM’s picture

@mastoll, your comment is probably best left in a new issue, since it is a different module than Field Collections.

igonzalez’s picture

@nerdstein How do I refer to the fields within the field collection items?

Greetings and many thanks