的情况下生成表单?" />
<?php $form = ActiveForm::begin(['id' => 'contact-form']); ?> <?= $form->field($model, 'email', [ 'inputOptions' => [ 'placeholder' => 'Ihre E-Mail Adresse', 'class' => 'newsletter-cta-mail' ] ])->label(false)->textInput(); ?> <?= Html::submitButton('20€ Gutschein sichern', ['class' => 'green newsletter-cta-button', 'name' => 'contact-button', 'value' => 'hallo']) ?> <?php ActiveForm::end(); ?>
结果为:
<form id="contact-form" action="/" method="post" role="form"> <input type="hidden" name="_csrf" value="WFlFWnIwU1Y3HnQKSn06GG46PXcjQRUzNCA9KhRiYCxvFXQ9RHIiPA=="> <div class="form-group field-newsletterform-email required has-error"> <input type="text" id="newsletterform-email" class="newsletter-cta-mail" name="NewsletterForm[email]" placeholder="Ihre E-Mail Adresse"> <p class="help-block help-block-error">Verification Code cannot be blank.</p> </div> <button type="submit" class="green newsletter-cta-button" name="contact-button" value="hallo">20€ Gutschein sichern</button></form>
但我不需要包装
如何禁用此功能?
你可以简单地使用Html::activeTextInput() http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#activeTextInput()-detail :
<?= Html::activeTextInput($model, 'email', ['placeholder' => 'Ihre E-Mail Adresse', 'class' => 'newsletter-cta-mail']); ?>
或者改变ActiveForm::$fieldConfig http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html#%24fieldConfig-detail配置 :
ActiveForm::begin([ 'id' => 'contact-form', 'fieldConfig' => [ 'options' => [ 'tag' => false, ], ], ]);