At #2226493: Apply formatters and widgets to Node base fields, we lost hours trying to figure out why a new widget wouldn't work. It turned out that we were returning $element['value'] = array(…) (like most widgets do), while we should have been returning $element['target_id'] = array(…)… because an entity_reference item's main property is tarrget_id. This is extremely hard to debug. And a very simple mistake to make.
I talked to fago and we agreed that to improve DX, we should just throw an exception, so that the developer is immediately made aware upon trying the widget.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | widget_values_main_property_exception-2228041-1.patch | 1.92 KB | wim leers |
Comments
Comment #1
wim leersComment #3
fagoShould be !isset($values[$name]) not? Could explain all the fails?
Comment #4
berdirI can see at least three problems with this:
- We have now field types that have no main property, like the MapItem.
- Won't this be a problem for empty fields?
- It is AFAIK valid to just return $value instead of array('value' => $value).
Comment #5
berdirBump :)
Comment #6
mgiffordJust unassigning issues that haven't been developed for a bit in the D8 queue.
Comment #20
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #21
smustgrave commentedas a major wanted to bump 1 more time.