简体   繁体   English

如何为Yii2 Captcha小部件设置标签?

[英]How to set label for Yii2 Captcha widget?

Using Yii2, I realise that the template property for a CAPTCHA Widget only has an {image} and {input} token. 使用Yii2,我意识到CAPTCHA Widget的template属性只有一个{image}{input}令牌。 My question is, How do I actually set the {label} token via the template property and move it around, so maybe I want it under the {image} for example? 我的问题是,我实际上如何通过template属性设置{label}令牌并将其移动,所以例如我可能想要在{image}下?

I have tried the following: (setting the label inside the field like you would an ordinary form field). 我尝试了以下操作:(像在普通表单字段中一样在field内设置标签)。

<?= $form->field($model, 'verifyCode', ['template' => '{label}'])->widget(Captcha::className(), [
    'template' => '<div class="col-xs-12">{image}</div><div class="col-xs-12">{input}</div>',
    'options' => ['placeholder' => 'CAPTCHA Code', 'class' => 'form-control']
]) ?>

Thanks!! 谢谢!!

<?= $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::classname(),['options' => [
                     'placeholder' => 'Please enter the letters displayed above'
                        , 'Class' => 'form-control'
                        , 'style' => 'Top-margin: 10px;'
                ]])->label('Security Code')?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM