Value of the CHtml::activeTextArea() can now be set through $htmlOptions['value']. #1446

Merged
merged 1 commit into from Sep 21, 2012

Conversation

Projects
None yet
2 participants
@resurtm
Contributor

resurtm commented Sep 21, 2012

Sample:

<?php $loginForm=new LoginForm(); ?>
<?php $loginForm->username='user1'; ?>
<?php echo CHtml::activeTextArea($loginForm,'username',array('value'=>'user2')); ?>

This enhancement is not needed for CHtml::textArea() because it's value already could be specified through second parameter.

Right now i have to do ugly things to pass this defect:

<!-- this is a view -->
<?php
$oldValue=$model->value2; // i want to keep $model->value2 untouched, but in a view, when shown to the user it should be altered
$model->value2=$model->value1;
echo CHtml::activeTextArea($model,'value2');
$model->value2=$oldValue;
?>

With this enhancement it would look much better:

<!-- this is a view -->
<?php echo CHtml::activeTextArea($model,'value2',array('value'=>$model->value1)); ?>
@mdomba

This comment has been minimized.

Show comment Hide comment
@mdomba

mdomba Sep 21, 2012

Member

NOt sure about this... as this is an "active" method it's expected to get the value of the model attribute not of the htmlOption value.

Member

mdomba commented Sep 21, 2012

NOt sure about this... as this is an "active" method it's expected to get the value of the model attribute not of the htmlOption value.

@resurtm

This comment has been minimized.

Show comment Hide comment
@resurtm

resurtm Sep 21, 2012

Contributor

@mdomba, but CHtml::activeInputField() and CHtml::activeTextField() already allows to do the same. This PR would gain more consistency. ;-)

Contributor

resurtm commented Sep 21, 2012

@mdomba, but CHtml::activeInputField() and CHtml::activeTextField() already allows to do the same. This PR would gain more consistency. ;-)

@resurtm

This comment has been minimized.

Show comment Hide comment
@resurtm

resurtm Sep 21, 2012

Contributor

as this is an "active" method it's expected to get the value of the model attribute not of the htmlOption value

Not just getting the value from the model, but:

  1. Encapsulate CHtml::resolveNameID() call. Generate ID and name from the model name and the attribute name.
  2. Encapsulate CHtml::clientChange() call.
  3. Attach model errors automatically to the according fields (visually).
  4. Passing model values to the form fields.

I think it's natural to allow developer to alter some of these clauses.

Contributor

resurtm commented Sep 21, 2012

as this is an "active" method it's expected to get the value of the model attribute not of the htmlOption value

Not just getting the value from the model, but:

  1. Encapsulate CHtml::resolveNameID() call. Generate ID and name from the model name and the attribute name.
  2. Encapsulate CHtml::clientChange() call.
  3. Attach model errors automatically to the according fields (visually).
  4. Passing model values to the form fields.

I think it's natural to allow developer to alter some of these clauses.

@mdomba

This comment has been minimized.

Show comment Hide comment
@mdomba

mdomba Sep 21, 2012

Member

wow.. you are right... I never used that so got surprised by Yii this time :)

Member

mdomba commented Sep 21, 2012

wow.. you are right... I never used that so got surprised by Yii this time :)

@resurtm

This comment has been minimized.

Show comment Hide comment
@resurtm

resurtm Sep 21, 2012

Contributor

@mdomba, okay, let's wait for others opinion on this. :)

Contributor

resurtm commented Sep 21, 2012

@mdomba, okay, let's wait for others opinion on this. :)

mdomba added a commit that referenced this pull request Sep 21, 2012

Merge pull request #1446 from resurtm/activetextarea-htmloptions-value
Value of the CHtml::activeTextArea() can now be set through $htmlOptions['value'].
[ci skip]

@mdomba mdomba merged commit 7bf088a into yiisoft:master Sep 21, 2012

@ghost ghost assigned mdomba Sep 21, 2012

@mdomba

This comment has been minimized.

Show comment Hide comment
@mdomba

mdomba Sep 21, 2012

Member

No need to wait... as you pointed above this brings more consistency.

Thanks for your work.

Member

mdomba commented Sep 21, 2012

No need to wait... as you pointed above this brings more consistency.

Thanks for your work.

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