Bug #16074
closedparams.textarea setting causes form element to disappear
0%
Description
Setting for a FORM object:
params.textarea = style="width=100%;border:1px solid red"
will cause the textarea form element to disappear.
An analysis of the problem is given below as Additional Information.
Causeof problem:
In file class.tslib_content.php, function FORM
the $addParams string is merged into the format string of the
sprintf function call used to construct $fieldCode:
$fieldCode=sprintf('<textarea name="%s"'.$elementIdAttribute.' cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
$confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
The % in the width=100% specifier of the style attribute causes sprintf to return an empty string.
Workaround: use %% instead of % in params. settings
Note that this not really a good solution.
To somebody writing TYPOSCRIPT code it is rarely known whether the value of an attribute is inserted into an sprintf call by the method shown above.
Note also that this workaround only works, because the $fieldCode string is not itself processed by another printf or sprintf later.
Remedy: Instead of inserting the string itself into the format, specify it as another data parameter and include it in the output it by another %s.
This is a general problem that may arise with other TYPOSCRIPT property values in other functions as well, where the same style of coding is employed.
(issue imported from #M3309)
Updated by Ernesto Baschny over 18 years ago
Placing the $addParam outside the sprintf seems the obvious solution and replacing that with "%s" in the formatting-string. That's just ugly code. :) As this seems to happen in some other places in the FORM code, I'll consider to fix when I make some changes on that code again.