Skip to content

Commit

Permalink
Allow caption to be a textarea rather than a text field (see #2527)
Browse files Browse the repository at this point in the history
Description
-----------

An image caption shouldn't be limited to 255 chars only, that makes no sense to me.

That's the result:

<img width="1174" alt="Bildschirmfoto 2020-11-27 um 13 12 19" src="https://user-images.githubusercontent.com/481937/100448322-60b94a80-30b2-11eb-88f2-99f8fb499e4d.png">

Commits
-------

06f57ee Allow caption to be a textarea rather than a text field limited to 255 chars
b346f65 CS
0c23a1f Merge branch '4.9' into fix/allow-textarea-for-meta-caption
  • Loading branch information
Toflar committed Dec 7, 2020
1 parent 77c79be commit 8605bc4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core-bundle/src/Resources/contao/dca/tl_files.php
Expand Up @@ -233,7 +233,7 @@
'title' => 'maxlength="255"',
'alt' => 'maxlength="255"',
'link' => array('attributes'=>'maxlength="255"', 'dcaPicker'=>true),
'caption' => 'maxlength="255"'
'caption' => array('type'=>'textarea')
)
),
'sql' => "blob NULL"
Expand Down
5 changes: 4 additions & 1 deletion core-bundle/src/Resources/contao/themes/flexible/main.css
Expand Up @@ -1541,11 +1541,14 @@ ul.sgallery li {
width:18%;
margin-top:9px;
}
.tl_metawizard .tl_text {
.tl_metawizard .tl_text, .tl_metawizard .tl_textarea {
float:left;
width:82%;
margin:1px 0;
}
.tl_metawizard .tl_textarea {
resize: vertical;
}
.tl_metawizard .tl_text + a {
top:6px;
}
Expand Down

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion core-bundle/src/Resources/contao/widgets/MetaWizard.php
Expand Up @@ -144,7 +144,17 @@ public function generate()
// Take the fields from the DCA (see #4327)
foreach ($this->metaFields as $field=>$fieldConfig)
{
$return .= '<label for="ctrl_' . $this->strId . '_' . $field . '_' . $count . '">' . $GLOBALS['TL_LANG']['MSC']['aw_' . $field] . '</label> <input type="text" name="' . $this->strId . '[' . $lang . '][' . $field . ']" id="ctrl_' . $this->strId . '_' . $field . '_' . $count . '" class="tl_text" value="' . StringUtil::specialchars($meta[$field]) . '"' . (!empty($fieldConfig['attributes']) ? ' ' . $fieldConfig['attributes'] : '') . '>';
$return .= '<label for="ctrl_' . $this->strId . '_' . $field . '_' . $count . '">' . $GLOBALS['TL_LANG']['MSC']['aw_' . $field] . '</label>';

if (isset($fieldConfig['type']) && 'textarea' === $fieldConfig['type'])
{
$return .= '<textarea name="' . $this->strId . '[' . $lang . '][' . $field . ']" id="ctrl_' . $this->strId . '_' . $field . '_' . $count . '" class="tl_textarea"' . (!empty($fieldConfig['attributes']) ? ' ' . $fieldConfig['attributes'] : '') . '>' . $meta[$field] . '</textarea>';
}
else
{
$return .= '<input type="text" name="' . $this->strId . '[' . $lang . '][' . $field . ']" id="ctrl_' . $this->strId . '_' . $field . '_' . $count . '" class="tl_text" value="' . StringUtil::specialchars($meta[$field]) . '"' . (!empty($fieldConfig['attributes']) ? ' ' . $fieldConfig['attributes'] : '') . '>';
}


// DCA picker
if (isset($fieldConfig['dcaPicker']) && (\is_array($fieldConfig['dcaPicker']) || $fieldConfig['dcaPicker'] === true))
Expand Down

0 comments on commit 8605bc4

Please sign in to comment.