Skip to content

Commit

Permalink
GetDKAN#4132: Provide text_format render element
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-korn committed Feb 22, 2024
1 parent 6850890 commit fc679fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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 ($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

0 comments on commit fc679fa

Please sign in to comment.