使用Yii2,我意识到CAPTCHA Widget的模板属性只有{image}
和{input}
令牌。我的问题是,我如何通过模板属性实际设置{label}
令牌并移动它,所以我想在{image}
之下想要它?
我尝试过以下操作:(在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']
]) ?>
谢谢!
答案 0 :(得分:-1)
<?= $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')?>