summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc25
1 files changed, 18 insertions, 7 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 4ad8e08d8..c8848f5cd 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -7433,16 +7433,20 @@ function entity_form_field_validate($entity_type, $form, &$form_state) {
*
* During the submission handling of an entity form's "Save", "Preview", and
* possibly other buttons, the form state's entity needs to be updated with the
- * submitted form values. Each entity form implements its own
- * $form['#builder_function'] for doing this, appropriate for the particular
- * entity and form. Many of these entity builder functions can call this helper
- * function to re-use its logic of copying $form_state['values'][PROPERTY]
- * values to $entity->PROPERTY for all entries in $form_state['values'] that are
- * not field data, and calling field_attach_submit() to copy field data.
+ * submitted form values. Each entity form implements its own builder function
+ * for doing this, appropriate for the particular entity and form, whereas
+ * modules may specify additional builder functions in $form['#entity_builders']
+ * for copying the form values of added form elements to entity properties.
+ * Many of the main entity builder functions can call this helper function to
+ * re-use its logic of copying $form_state['values'][PROPERTY] values to
+ * $entity->PROPERTY for all entries in $form_state['values'] that are not field
+ * data, and calling field_attach_submit() to copy field data. Apart from that
+ * this helper invokes any additional builder functions that have been specified
+ * in $form['#entity_builders'].
*
* For some entity forms (e.g., forms with complex non-field data and forms that
* simultaneously edit multiple entities), this behavior may be inappropriate,
- * so the #builder_function for such forms needs to implement the required
+ * so the builder function for such forms needs to implement the required
* functionality instead of calling this function.
*/
function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_state) {
@@ -7457,6 +7461,13 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st
$entity->$key = $value;
}
+ // Invoke all specified builders for copying form values to entity properties.
+ if (isset($form['#entity_builders'])) {
+ foreach ($form['#entity_builders'] as $function) {
+ $function($entity_type, $entity, $form, $form_state);
+ }
+ }
+
// Copy field values to the entity.
if ($info['fieldable']) {
field_attach_submit($entity_type, $entity, $form, $form_state);