TbHtml::activeTextArea PHP Method

activeTextArea() public static method

Generates a text area input for a model attribute.
public static activeTextArea ( CModel $model, string $attribute, array $htmlOptions = [] ) : string
$model CModel the data model.
$attribute string the attribute.
$htmlOptions array additional HTML attributes.
return string the generated text area.
    public static function activeTextArea($model, $attribute, $htmlOptions = array())
    {
        // In case we do need to create a div container for the text area
        $containerOptions = array();
        // Get the intended input width before the rest of the options are normalized
        self::addSpanClass($htmlOptions);
        self::addColClass($htmlOptions);
        $col = self::popColClasses($htmlOptions);
        $htmlOptions = self::normalizeInputOptions($htmlOptions);
        self::addCssClass('form-control', $htmlOptions);
        $output = '';
        if (!empty($col)) {
            self::addCssClass($col, $containerOptions);
            $output .= self::openTag('div', $containerOptions);
        }
        $output .= parent::activeTextArea($model, $attribute, $htmlOptions);
        if (!empty($col)) {
            $output .= '</div>';
        }
        return $output;
    }

Usage Example

Example #1
0
<?php 
$profileFields = Profile::getFields();
if ($profileFields) {
    foreach ($profileFields as $field) {
        ?>
	<div class='row'>
		<?php 
        echo $form->labelEx($profile, $field->varname);
        ?>
		<?php 
        if ($widgetEdit = $field->widgetEdit($profile)) {
            echo $widgetEdit;
        } elseif ($field->range) {
            echo $form->dropDownList($profile, $field->varname, Profile::range($field->range));
        } elseif ($field->field_type == 'TEXT') {
            echo TbHtml::activeTextArea($profile, $field->varname, array('rows' => 6, 'cols' => 50));
        } else {
            echo $form->textField($profile, $field->varname, array('size' => 60, 'maxlength' => $field->field_size ? $field->field_size : 255));
        }
        ?>
		<?php 
        echo $form->error($profile, $field->varname);
        ?>
	</div>
			<?php 
    }
}
?>
	

<?php 
All Usage Examples Of TbHtml::activeTextArea
TbHtml