Thanks for saying hello on IRC.

We've made a form builder thing, that allows us to put any field from any entity into the form and have them all save to the right place at the end. This was working well with most fields but we noticed that the field collection table widget didn't display properly.

It looks like field_collection_table uses a form_alter alter hook and makes use of #entity_type, #bundle and the name of the array item for the field, then causes some theme hooks to be triggered than render the widget differently.

Unfortunately, none of these things are available in our forms.

Why was collections tables built this way, rather than using a custom widget? What were the reasons/problems that led to the decision?

This is something that we're going to have to fix for a client within like a week, so we're happy to put all the work in. Just wanted to get your input so we knew what we were up against.

Comments

andrewbelcher’s picture

The work around for it in case anyone else needs it is to set the following two settings manually on your form:

$form['field_example_field'][LANGUAGE_NONE]['#pre_render'][] = 'field_collection_table_pre_render_multiple_fields';
$form['field_example_field'][LANGUAGE_NONE]['#theme'] = 'field_collection_table_multiple_value_fields';
rooby’s picture

Status: Active » Fixed

Unfortunately, like you say, this doesn't work because it relies on the field being on an entity form.

For now the workaround in #1 should suffice but I have opened an issue to change it - #1946978: Use custom widget instead of reusing existing one and then form altering

PS: did you finish that project of the dynamic form?

rlmumford’s picture

Hi rooby! Thanks for the reply. I might have time to submit a patch to the other issue at some point this week.

The dynamic forms project is still under construction, but definitely usable by a developer. It's in a sandbox at the moment:

Flexible Forms

rooby’s picture

Cool, I'll have to check it out some time.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.