如何在yii inputfield中添加占位符文本?

时间:2015-08-31 20:56:09

标签: yii yii-extensions

我使用clevertech扩展YII,任何人都知道如何在输入中添加我自己的自定义占位符文本。 以下是输入字段的示例:

<?php echo $form->textFieldGroup(
            $model,
            'textField',
            array(
                'wrapperHtmlOptions' => array(
                    'class' => 'col-sm-5',
                ),
                'hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.'
            )
        ); ?>

2 个答案:

答案 0 :(得分:2)

您可以将placeholder添加到html属性中,如下所示:

<?php echo $form->textFieldGroup(
    $model,
    'textField',
    array(
        'wrapperHtmlOptions' => array(
            'class' => 'col-sm-5',
        ),
        'hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.',
        'widgetOptions' => array(
            'options' => array(
                'placeholder' => 'Placeholder content',
            ),
        ),
    )
); ?>

请参阅http://yiibooster.clevertech.biz/widgets/forms/view/activeform.html

答案 1 :(得分:0)

试试这个......

<?php echo $form->textFieldGroup(
        $model,
        'textField',
        array(
            'wrapperHtmlOptions' => array(
                'class' => 'col-sm-5',
            ),
            'widgetOptions'=>array(
                'htmlOptions'=>array('placeholder' => 'Placeholder content')
        )
            'hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.'
        )
    ); ?>