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
Issue fork custom_formatters-3478998
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
Comment #2
logosur commentedComment #5
mohd sahzad commentedComment #6
decipheredThanks Mohd. Committed to 4.1.x
Extended your fix to also patch FormatterForm::getFieldTypes() which had the same render() on string bug.