Skip to content

Commit

Permalink
Properly rename textarea tags for text metadata elements when embedde…
Browse files Browse the repository at this point in the history
…d in view bundle template
  • Loading branch information
collectiveaccess committed Jan 6, 2025
1 parent d692e1c commit c37380e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions app/helpers/htmlFormHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ function caHTMLTextInput($name, $attributes=null, $options=null) {
$is_textarea = false;
$va_styles = array();

$tag_name = caGetOption('textAreaTagName', $options, 'textarea');

if(isset($attributes['style']) && $attributes['style']) {
$va_styles[] = $attributes['style'];
}
Expand Down Expand Up @@ -245,7 +247,7 @@ function caHTMLTextInput($name, $attributes=null, $options=null) {

$attr_string = _caHTMLMakeAttributeString($attributes, $options);
$element .= "<div id=\"{$name}_container\" style='width: {$width}px; height: {$height}px; overflow-y: auto;'>
<textarea name=\"{$name}\" id=\"{$name}\">{$attributes['value']}</textarea></div>
<{$tag_name} name=\"{$name}\" id=\"{$name}\">{$attributes['value']}</{$tag_name}></div>
<style>
#{$name}_container .ck-editor__editable_inline {
min-height: calc({$height}px - 100px);
Expand Down Expand Up @@ -287,7 +289,6 @@ function caHTMLTextInput($name, $attributes=null, $options=null) {
$o_config = Configuration::load();
if(!is_array($va_toolbar_config = $o_config->getAssoc(caGetOption('cktoolbar', $options, 'wysiwyg_editor_toolbar')))) { $va_toolbar_config = []; }
} elseif ($is_textarea) {
$tag_name = caGetOption('textAreaTagName', $options, 'textarea');
$value = $attributes['value'] ?? null;
if ($attributes['size'] ?? null) { $attributes['cols'] = $attributes['size']; }
unset($attributes['size']);
Expand Down
19 changes: 11 additions & 8 deletions app/lib/Attributes/Values/TextAttributeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,23 @@ public function htmlFormElement($element_info, $options=null) {
$class = trim((isset($options['class']) && $options['class']) ? $options['class'] : '');
$element = '';

$opts = [
$attr = [
'width' => $width.(is_numeric($width) ? 'px' : ''),
'height' => $height.(is_numeric($height) ? 'px' : ''),
'value' => '{{'.$element_info['element_id'].'}}',
'id' => '{fieldNamePrefix}'.$element_info['element_id'].'_{n}',
'class' => "{$class}",
'class' => "{$class}"
];
$opts = [
'textAreaTagName' => caGetOption('textAreaTagName', $options, null)
];
$attributes = caGetOption('attributes', $options, null);
if(is_array($attributes)) {
$opts = array_merge($attributes, $opts);
$attr = array_merge($attributes, $opts);
}

if (caGetOption('readonly', $options, false)) {
$opts['disabled'] = 1;
$attr['disabled'] = 1;
}

if ($settings['usewysiwygeditor'] ?? null) {
Expand Down Expand Up @@ -439,7 +442,7 @@ public function htmlFormElement($element_info, $options=null) {

$element .= "<div style='width: {$width_w_suffix}; height: {$height_w_suffix}; overflow-y: auto;' class='{fieldNamePrefix}{$element_info['element_id']}_container_{n} ckeditor-wrapper'>".caHTMLTextInput(
'{fieldNamePrefix}'.$element_info['element_id'].'_{n}',
$opts
$attr, $opts
)."</div><style>
.{fieldNamePrefix}{$element_info['element_id']}_container_{n} .ck-editor__editable_inline {
min-height: calc({$height}px - 100px);
Expand Down Expand Up @@ -468,20 +471,20 @@ public function htmlFormElement($element_info, $options=null) {
".json_encode($quill_opts)."
);
</script>\n";
$opts['style'] = 'display: none;';
$attr['style'] = 'display: none;';
$element .= "<div id='{fieldNamePrefix}".$element_info['element_id']."_editor_{n}' style='height: {$height_w_suffix};' class='ql-ca-editor'></div>";

$element .= caHTMLTextInput(
'{fieldNamePrefix}'.$element_info['element_id'].'_{n}',
$opts
$attr, $opts
);
$element .= "</div>\n";
break;
}
} else {
$element .= caHTMLTextInput(
'{fieldNamePrefix}'.$element_info['element_id'].'_{n}',
$opts
$attr, $opts
);
}

Expand Down

0 comments on commit c37380e

Please sign in to comment.