I notice the form callback for the product inline form does this:
// Ensure this include file is loaded when the form is rebuilt from the cache.
$form_state['build_info']['files']['inline_form'] = drupal_get_path('module', 'inline_entity_form') . '/includes/commerce_product.type.inc';
Given the path and name of this file gets defined in hook_inline_entity_type_info(), could inline_entity_form_field_widget_form() take care of setting this and save each implementation of this a bit of work?
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 1572452-refactor.patch | 14.51 KB | bojanz |
| #2 | 1572452-2.inline_entity_form.build-info-files.patch | 3.42 KB | joachim |
| #1 | 1572452.inline_entity_form.build-info-files.patch | 2.82 KB | joachim |
Comments
Comment #1
joachim commentedHere's a patch which seems to work. At least, nothing blows up with it ... inline_entity_form_field_widget_form() has to be the longest function I've ever seen so I'm not 100% sure of what I'm doing in there :)
Comment #2
joachim commentedAdded some docs about this feature.
Comment #3
bojanz commentedOkay, so we have two problems:
1) Type forms contain things that can be added automatically (the pre_render callback, the final #element_validate callback, the build_info).
2) The inline_entity_form_field_widget_form() function is a huge barely-understandable monster.
Here's a refactoring that handles #1 and makes #2 better.
This was also a requirement for easily adding a form alter hook for type forms without making #2 even worse.
Comment #4
bojanz commentedAaand, committed. Feel free to comment on the patch, it's never too late for a followup :)
Comment #5
joachim commented> 2) The inline_entity_form_field_widget_form() function is a huge barely-understandable monster
Heh, yes. I barely understand it :(
The patch does look like it simplifies quite a few things. Will try another stab at implementing something with this soon!