Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4132: Provide text_format render element #4133

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/json_form_widget/src/ValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public function handleStringValues($formValues, $property) {
if (isset($formValues[$property]['select'])) {
return $formValues[$property][0] ?? NULL;
}
// Handle text_format.
if (isset($formValues[$property]['value'])) {
return $formValues[$property]['value'];
}
return !empty($formValues[$property]) && is_string($formValues[$property]) ? $this->cleanSelectId($formValues[$property]) : FALSE;
}

Expand Down
7 changes: 7 additions & 0 deletions modules/json_form_widget/src/WidgetRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ public function handleUploadOrLinkElement($spec, array $element) {
*/
public function handleTextareaElement($spec, array $element) {
$element['#type'] = 'textarea';
if (isset($spec->text_format)) {
$element['#type'] = 'text_format';
$element['#format'] = $spec->text_format;
$element['#allowed_formats'] = [
$spec->text_format,
];
}
if (isset($spec->rows)) {
$element['#rows'] = $spec->rows;
}
Expand Down