comparison core/modules/field/field.api.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 1fec387a4317
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
136 136
137 /** 137 /**
138 * Alter forms for field widgets provided by other modules. 138 * Alter forms for field widgets provided by other modules.
139 * 139 *
140 * @param $element 140 * @param $element
141 * The field widget form element as constructed by hook_field_widget_form(). 141 * The field widget form element as constructed by
142 * \Drupal\Core\Field\WidgetBaseInterface::form().
142 * @param $form_state 143 * @param $form_state
143 * The current state of the form. 144 * The current state of the form.
144 * @param $context 145 * @param $context
145 * An associative array containing the following key-value pairs: 146 * An associative array containing the following key-value pairs:
146 * - form: The form structure to which widgets are being attached. This may be 147 * - form: The form structure to which widgets are being attached. This may be
150 * \Drupal\Core\Field\FieldItemListInterface object. 151 * \Drupal\Core\Field\FieldItemListInterface object.
151 * - delta: The order of this item in the array of subelements (0, 1, 2, etc). 152 * - delta: The order of this item in the array of subelements (0, 1, 2, etc).
152 * - default: A boolean indicating whether the form is being shown as a dummy 153 * - default: A boolean indicating whether the form is being shown as a dummy
153 * form to set default values. 154 * form to set default values.
154 * 155 *
156 * @see \Drupal\Core\Field\WidgetBaseInterface::form()
155 * @see \Drupal\Core\Field\WidgetBase::formSingleElement() 157 * @see \Drupal\Core\Field\WidgetBase::formSingleElement()
156 * @see hook_field_widget_WIDGET_TYPE_form_alter() 158 * @see hook_field_widget_WIDGET_TYPE_form_alter()
157 */ 159 */
158 function hook_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { 160 function hook_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
159 // Add a css class to widget form elements for all fields of type mytype. 161 // Add a css class to widget form elements for all fields of type mytype.
170 * Modules can implement hook_field_widget_WIDGET_TYPE_form_alter() to modify a 172 * Modules can implement hook_field_widget_WIDGET_TYPE_form_alter() to modify a
171 * specific widget form, rather than using hook_field_widget_form_alter() and 173 * specific widget form, rather than using hook_field_widget_form_alter() and
172 * checking the widget type. 174 * checking the widget type.
173 * 175 *
174 * @param $element 176 * @param $element
175 * The field widget form element as constructed by hook_field_widget_form(). 177 * The field widget form element as constructed by
178 * \Drupal\Core\Field\WidgetBaseInterface::form().
176 * @param $form_state 179 * @param $form_state
177 * The current state of the form. 180 * The current state of the form.
178 * @param $context 181 * @param $context
179 * An associative array. See hook_field_widget_form_alter() for the structure 182 * An associative array. See hook_field_widget_form_alter() for the structure
180 * and content of the array. 183 * and content of the array.
181 * 184 *
185 * @see \Drupal\Core\Field\WidgetBaseInterface::form()
182 * @see \Drupal\Core\Field\WidgetBase::formSingleElement() 186 * @see \Drupal\Core\Field\WidgetBase::formSingleElement()
183 * @see hook_field_widget_form_alter() 187 * @see hook_field_widget_form_alter()
184 */ 188 */
185 function hook_field_widget_WIDGET_TYPE_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { 189 function hook_field_widget_WIDGET_TYPE_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
186 // Code here will only act on widgets of type WIDGET_TYPE. For example, 190 // Code here will only act on widgets of type WIDGET_TYPE. For example,