User tests: Successful: Unsuccessful:
The Max Length was printing just the NUMBER as the attribute instead of maxlength="NUMBER"
See screenshot
None
Status | New | ⇒ | Pending |
Category | ⇒ | Layout |
Labels |
Added:
?
|
@Quy , according to the textarea field layout code this will only work if the $maxlength
has the entire attribute instead of just an integer, for example, if the $maxlength = 'maxlength="1000"'
I just noticed there's no @var
documentation, but IMHO it should work just like the other variables, which contain the value only instead of the attribute_name="attribute_value"
Your PR will break the custom textarea field. See markup.
<textarea name="jform[com_fields][text-area]" id="jform_com_fields_text_area" class="form-control" maxlength=" maxlength="1000"" ></textarea>
The character count requires two attributes in the xml
maxlength="160"
charcounter="true"
@machadoug You have the same issue with rows
(4) and cols
(20) attributes displaying only the values. It is not happening in core so it must be on your end. Please provide steps/code to reproduce.
@machadoug I suspect you use the textarea layout with your own field,
because for core textarea
field the maxlength
is set in the class:
joomla-cms/libraries/src/Form/Field/TextareaField.php
Lines 180 to 189 in 3544d8b
It looks strange to me, but it works like that since ~3.7 version
I was indeed using a custom Textarea field in my extension. I was under the impression that we should use only the attribute value, not attribute="value"
. Like the onchange, onclick and autocomplete attributes.
Maybe we should include something in the code documentation explaining it's a string and not an integer?
* @var string $rows rows attribute for the field.
* @var string $cols cols attribute for the field.
* @var string $maxlength maxlength attribute for the field.
I was under the impression that we should use only the attribute value, not attribute="value". Like the onchange, onclick and autocomplete attributes.
That is correct expectation.
But I cannot say why it like that for textarea.
Would be good to fix it. Only need to care about backward compatibility here.
The fix should move this
joomla-cms/libraries/src/Form/Field/TextareaField.php
Lines 179 to 181 in 3544d8b
And in layout doing something like:
$maxlengthAttr = '';
if ($maxlengt)
{
$maxlengthAttr = is_numeric($maxlength) ? ' maxlength="' . $maxlength . '"' : $maxlength;
}
The same for rows and cols attribute.
Labels |
Added:
Information Required
|
Labels |
Removed:
Information Required
|
Category | Layout | ⇒ | Layout Libraries |
@machadoug I have added that changes to your PR
It ready for testing:
Make sure textarea field still working as before.
Labels |
Added:
?
?
Removed: ? |
This pull request has automatically rebased to 4.2-dev.
This pull requests has been automatically converted to the PSR-12 coding standard.
Labels |
Added:
PBF
?
?
Removed: ? ? |
Labels |
Added:
?
Removed: ? |
I have tested this item
Labels |
Removed:
?
|
Labels |
Added:
Conflicting Files
|
Labels |
Added:
PR-4.3-dev
?
Removed: Conflicting Files ? |
This pull request has been automatically rebased to 4.4-dev.
Labels |
Added:
bug
?
PR-4.4-dev
Removed: PR-4.3-dev ? |
Labels |
Added:
Small
Removed: ? |
Title |
|
This pull request has been automatically rebased to 5.2-dev.
Title |
|
Labels |
Added:
PR-5.2-dev
|
I have tested this item ✅ successfully on 82dc13f
I am not able to reproduce this issue.
Created a custom text area field with maxlength value.
The markup has the maxlength attribute.