Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixes #246: Added maxlength attribute to CHtml::activeTextArea #729

Closed
wants to merge 6 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

resurtm commented May 19, 2012

Fixes feature request #246. Patch submitted by @ejtb87.

Working testing code:

<?php
class TestForm extends CFormModel
{
    public $name;

    public function rules()
    {
        return array(
            array('name', 'length', 'max'=>50),
        );
    }
}
?>

<?php echo CHtml::activeTextArea(new TestForm(), 'name'); ?>
<?php echo CHtml::activeTextArea(new TestForm(), 'name', array('maxlength'=>25)); ?>

Emulation (imposing) of maxlength with jQuery/JS code for text fields and text areas should be discussed in other PR/issue/feature request. Not here.

Member

mdomba commented May 19, 2012

I'm not sure this is needed in the core... the performance is in question too as your code is traversing all the model validators and checks if it's a string validator with the max attribute set...

Contributor

resurtm commented May 19, 2012

But maxlength is already supported in activeInputField(). This patch just copies some code from there.

Member

mdomba commented May 19, 2012

You are right about the code...

I'm still not sure about adding this... the maxlength attribute has been added to textarea only in HTML5, previously this attribute is not valid, so it would produce non-valid XHTML code.

Contributor

resurtm commented May 21, 2012

What do you think about adding ability to CHtml which determines current doctype from the active layout? Knowing current doctype allows us to decide should we render maxlength attribute in textarea or not.

Member

mdomba commented May 21, 2012

How would that be implemented? Note that it should not affect performance for users that do not need this at all...

Contributor

resurtm commented May 22, 2012

Let me think some time on this problem. I will close it myself if there is no acceptable solution.

Contributor

resurtm commented Jun 28, 2012

I think we should close this PR and #246 with WontFix status. @mdomba's arguments are correct and reasonable. If somebody needs maxlength in CHtml::activeTextArea() he or she should use $htmlOptions method argument with explicitly specified maxlength value.

@mdomba mdomba closed this Jun 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment