Skip to content

Commit

Permalink
feat: Make the input box for the field text a textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
live627 committed Feb 27, 2022
1 parent a0333a4 commit 2690700
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
31 changes: 30 additions & 1 deletion src/ManageCustomForm.php
Expand Up @@ -572,7 +572,7 @@ function ModifyCustomFormSettings($return_config = false)
'help' => 'customform_field_title',
),
array(
'text',
'large_text',
'field_text',
'value' => $data['text'],
'text_label' => $txt['customform_text'],
Expand Down Expand Up @@ -613,6 +613,35 @@ function ModifyCustomFormSettings($return_config = false)
$scripturl . '?action=admin;area=modsettings;sa=customform;field_id=' . $field_id . ';update;';
$context['page_title'] = $txt['customform_tabheader'];
$context['sub_template'] = 'show_settings';
$context['html_headers'] .= '
<script>
window.addEventListener("DOMContentLoaded", function()
{
var
el = document.createElement("div"),
textarea = document.getElementById("field_text"),
textareaLengthCheck = () =>
{
var charactersLeft = 4096 - textarea.value.length;
el.innerHTML = "Max characters: <b>4096</b>; characters remaining: <b>" + charactersLeft + "</b>";
if (charactersLeft < 0)
{
el.className = "error";
textarea.style.border = "1px solid red";
}
else
{
el.className = "";
textarea.style.border = "";
}
};
el.className = "smalltext";
textarea.parentNode.appendChild(el);
textarea.addEventListener("keyup", textareaLengthCheck, false);
textareaLengthCheck.call(textarea);
});
</script>';

// Finally prepare the settings array to be shown by the 'show_settings' template.
prepareDBSettingContext($config_vars);
Expand Down
2 changes: 1 addition & 1 deletion src/install.php
Expand Up @@ -94,7 +94,7 @@
array(
'name' => 'text',
'type' => 'varchar',
'size' => 150,
'size' => 4096,
'null' => true,
),
array(
Expand Down

0 comments on commit 2690700

Please sign in to comment.