Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The FieldWidget
annotation has this gem of a doxygen (D8 is full of i++ // increment i
level of comments):
/**
* Does the field widget handles multiple values at once.
*
* @var bool
*/
public $multiple_values = FALSE;
OK, that's useless. The WidgetInterface
has
* The BaseWidget methods will set the weight, field name and delta values for
* each form element. If there are multiple values for this field, the
* formElement() method will be called as many times as needed.
Really? Then what does multiple_values = TRUE
even do?? Of course, studying WidgetBase::form
will reveal setting multiple_values = TRUE
results in a single call as somewhat expected (from D7 experience) completely contradicting the doxygen.
Proposed resolution
Improve the documention
Remaining tasks
Read the code and then make a patch correcting the documenation
Comments
Comment #1
dawehnerI guess it would be also nice to have a pointer to a field which actually implement multiple_delta, I guess image/file is one?
Comment #2
chx CreditAttribution: chx commentedOptionsSelectWidget is also one, however it doesn't use $elements['value'] instead puts the widget in $elements directly making it at least very hard to extend -- but that's a different bug report :)
Edit: #2494311: OptionsSelectWidget wants to be reusable but fails miserably filed.
Comment #15
quietone CreditAttribution: quietone at PreviousNext commentedThis was a bugsmash target yesterday.
This is still valid.