summaryrefslogtreecommitdiff
path: root/modules/field/field.form.inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field/field.form.inc')
-rw-r--r--modules/field/field.form.inc48
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc
index 474cc7f5b..ec8b8d60e 100644
--- a/modules/field/field.form.inc
+++ b/modules/field/field.form.inc
@@ -411,3 +411,51 @@ function field_add_more_js($form, $form_state) {
return $element;
}
+
+/**
+ * Retrieves the field definition for a widget's helper callbacks.
+ *
+ * Widgets helper element callbacks (such as #process, #element_validate,
+ * #value_callback, ...) should use field_widget_field() and
+ * field_widget_instance() instead of field_info_field() and
+ * field_info_instance() when they need to access field or instance properties.
+ * See hook_field_widget_form() for more details.
+ *
+ * @see field_widget_instance()
+ * @see hook_field_widget_form()
+ *
+ * @param $element
+ * The structured array for the widget.
+ * @param $form_state
+ * The form state.
+ * @return
+ * The $field definition array for the current widget.
+ */
+function field_widget_field($element, $form_state) {
+ $info = $form_state['field'][$element['#field_name']][$element['#language']];
+ return $info['field'];
+}
+
+/**
+ * Provides the instance definition array for a widget's helper callbacks.
+ *
+ * Widgets helper element callbacks (such as #process, #element_validate,
+ * #value_callback, ...) should use field_widget_field() and
+ * field_widget_instance() instead of field_info_field() and
+ * field_info_instance() when they need to access field or instance properties.
+ * See hook_field_widget_form() for more details.
+ *
+ * @see field_widget_field()
+ * @see hook_field_widget_form()
+ *
+ * @param $element
+ * The structured array for the widget.
+ * @param $form_state
+ * The form state.
+ * @return
+ * The $instance definition array for the current widget.
+ */
+function field_widget_instance($element, $form_state) {
+ $info = $form_state['field'][$element['#field_name']][$element['#language']];
+ return $info['instance'];
+}