Problem/Motivation

The website encountered an unexpected error. Please try again later.
Error: Call to a member function render() on string in Drupal\custom_formatters\Plugin\CustomFormatters\FormatterType\FormatterPreset->settingsForm() (line 79 of modules/contrib/custom_formatters/src/Plugin/CustomFormatters/FormatterType/FormatterPreset.php).

Steps to reproduce

// Get Formatter type settings form.
$plugin_form = [];
$form['plugin'] = $formatter_type->settingsForm($plugin_form, $form_state);

Errors is thrown here:
modules/contrib/custom_formatters/src/Plugin/CustomFormatters/FormatterType/FormatterPreset.php:79
// Build formatters list.
$options = [];
$formatters = $this->formatterManager->getDefinitions();
foreach ($formatters as $formatter_name => $formatter) {
if (in_array($field_type, $formatter['field_types'])) {
/** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
$label = $formatter['label'];
$options[$formatter_name] = $label->render();
}
}

Proposed resolution

$label is string, so can't $label->render();

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kronenmix created an issue. See original summary.

logosur’s picture

Issue summary: View changes

mohd sahzad made their first commit to this issue’s fork.

mohd sahzad’s picture

Status: Active » Needs review
deciphered’s picture

Version: 4.0.0-beta1 » 4.1.x-dev
Status: Needs review » Fixed

Thanks Mohd. Committed to 4.1.x

Extended your fix to also patch FormatterForm::getFieldTypes() which had the same render() on string bug.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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