Problem/Motivation

Introduced in #2613924: Link text isn't marked as required

LinkWidget assumes that method ->get() exists on the field definition.

However, that method only exists for configurable fields.

Should use getName instead.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Assigned: Unassigned » larowlan

working on fix

larowlan’s picture

Status: Active » Needs review
StatusFileSize
new2.4 KB

Failing test

larowlan’s picture

StatusFileSize
new3.11 KB

Fix

sam152’s picture

Status: Needs review » Reviewed & tested by the community

So ::get exits on FieldConfigInterface inherited from ConfigEntityInterface::get, which has nothing to do with BaseFieldDefinitions, fix makes sense to me.

Checked out the docblock on FieldDefinitionInterface::getName:

* Returns the machine name of the field.
*
* This defines how the field data is accessed from the entity. For example,
* if the field name is "foo", then $entity->foo returns its data.

Which is pretty much the exact scenario in the widget, creating a selector to the form element, which matches the access scheme of the entity. The config based implementation is also defined as:

  public function getName() {
    return $this->field_name;
  }

So seems like the correct fix to me and a very low risk change.

The last submitted patch, 3: 2937889-fail.patch, failed testing. View results

larowlan’s picture

Title: LinkWidget no longer supports base fields with optional title » Regression: LinkWidget no longer supports base fields with optional title

  • xjm committed 7871cc0 on 8.5.x
    Issue #2937889 by larowlan, Sam152: Regression: LinkWidget no longer...
xjm’s picture

Committed to 8.5.x. Thanks!

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Didn't take the status :)

  • xjm committed b594b54 on 8.6.x
    Issue #2937889 by larowlan, Sam152: Regression: LinkWidget no longer...
xjm’s picture

@larowlan pointed out that for some reason I forgot to commit this to 8.6.x first. Fixed now!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.