Captcha is used together with CaptchaAction to provide CAPTCHA - a way
of preventing website spamming.
The image element rendered by Captcha will display a CAPTCHA image generated by
an action whose route is specified by [[captchaAction]]. This action must be an instance of CaptchaAction.
When the user clicks on the CAPTCHA image, it will cause the CAPTCHA image
to be refreshed with a new CAPTCHA.
You may use CaptchaValidator to validate the user input matches
the current CAPTCHA verification code.
The following example shows how to use this widget with a model attribute:
php
echo Captcha::widget([
'model' => $model,
'attribute' => 'captcha',
]);
The following example will use the name property instead:
php
echo Captcha::widget([
'name' => 'captcha',
]);
You can also use this widget in an [[\yii\widgets\ActiveForm|ActiveForm]] using the [[\yii\widgets\ActiveField::widget()|widget()]]
method, for example like this:
php
field($model, 'captcha')->widget(\yii\captcha\Captcha::classname(), [
configure additional widget properties here
]) ?>
$field = $form->field($model, "data[note]"); $field->template = "{input}"; echo $field->textArea(["class" => "form-control required", "placeholder" => Yii::t("app", "Notes for us / special request")]); $model->data = $data; ?> </div> <?php if ($model->captchaRequired) { ?> <div class="well"> <div class="row"> <?php echo $form->field($model, "captcha")->widget(Captcha::classname(), ['captchaAction' => ['/yes/order/captcha'], 'imageOptions' => ['class' => 'col-sm-4 col-xs-6', 'style' => 'margin:20px -5px 20px -5px;max-height:80px;cursor:pointer;'], 'options' => ['class' => 'col-sm-8 col-xs-6']]); ?> </div> </div> <?php } ?> <hr> <a onclick="$('#ordertab a[href=\'#summary\']').tab('show')" class="btn btn-warning btn-tab pull-left" ><?php echo Yii::t("app", "Previous"); ?> </a> <div class="form-group">
<?php $form = ActiveForm::begin(['id' => 'contact-form', 'action' => '/contact']); ?> <?php echo $form->field($model, 'email')->textInput(['placeholder' => 'email'])->label(false); ?> <div class="clear" style="height:20px"></div> <?php echo $form->field($model, 'subject')->textInput(['placeholder' => 'тема'])->label(false); ?> <div class="clear" style="height:20px"></div> <?php echo $form->field($model, 'body')->textArea(['rows' => 6])->label(false); ?> <div class="clear" style="height:20px"></div> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', 'options' => ['placeholder' => 'введите код']])->label(false); ?> <div class="clear" style="height:20px"></div> <div class="form-group"> <?php echo Html::submitButton('Отправить', ['class' => 'btn btn-primary', 'name' => 'contact-button']); ?> </div> <div class="clear" style="height:16px"></div> <span class="form_hint">Чтобы закрыть форму нажмите ESC</span> <?php ActiveForm::end(); ?> </div>
/** * @inheritdoc * * Takes the decision of rendering the widget or not depending on the number * of requests made from the client IP. */ public function run() { $captchaControl = new CaptchaControl(['model' => $this->model]); if ($captchaControl->hasReachedRequestNumber()) { parent::run(); } }
/** * @inheritdoc */ public function init() { /** * @var Module $m */ $m = Yii::$app->getModule('user'); if (!$m->getRegistrationSetting('randomUsernames', $this->userType)) { $this->attributes['username'] = ['type' => Form::INPUT_TEXT, 'options' => ['autocomplete' => 'new-username']]; } if (!$m->getRegistrationSetting('randomPasswords', $this->userType)) { $password = ['type' => Form::INPUT_PASSWORD]; if (in_array(Module::SCN_REGISTER, $m->passwordSettings['strengthMeter'])) { $password = ['type' => Form::INPUT_WIDGET, 'widgetClass' => PasswordInput::classname(), 'options' => ['options' => ['placeholder' => Yii::t('user', 'Password'), 'autocomplete' => 'off']]]; } $this->attributes['password'] = $password; } $this->attributes['email'] = ['type' => Form::INPUT_TEXT]; $captcha = ArrayHelper::getValue($m->registrationSettings, 'captcha', false); if ($captcha !== false && is_array($captcha)) { $this->attributes['captcha'] = ['type' => Form::INPUT_WIDGET, 'widgetClass' => Captcha::classname(), 'options' => $captcha['widget']]; } parent::init(); unset($this->attributes['rememberMe']); $this->leftFooter = $m->button(Module::BTN_HOME) . $m->button(Module::BTN_ALREADY_REGISTERED); $this->rightFooter = $m->button(Module::BTN_RESET_FORM) . ' ' . $m->button(Module::BTN_REGISTER); }
public function renderForm() { if (isset($this->form) && $this->form->active) { $model = $this->model; $activeForm = $this->activeForm; $fieldsHtml = FormUtil::getFieldsHtml($activeForm, $this->model, ['label' => $this->showLabel]); echo $fieldsHtml; if ($this->form->captcha) { if ($this->showLabel) { $captchaHtml = $activeForm->field($model, 'captcha')->widget(Captcha::classname(), ['options' => ['placeholder' => 'Captcha*']]); } else { $captchaHtml = $activeForm->field($model, 'captcha')->label(false)->widget(Captcha::classname(), ['options' => ['placeholder' => 'Captcha*']]); } echo $captchaHtml; } if (!isset($this->formActions)) { echo "<div class='frm-actions'><input type='submit' value='Submit' /></div>"; } else { echo $this->formActions; } } else { echo "<div class='warning'>Form submission is disabled by site admin.</div>"; } }
<div class="login text-center"> <div class="login-form col-lg-5"> <div class="panel panel-default text-left"> <div class="panel-heading"><strong>登录</strong></div> <div class="panel-body"> <?php $form = ActiveForm::begin(['id' => 'login', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['labelOptions' => ['class' => 'col-lg-2 control-label'], 'template' => "{label}<div class='col-lg-8'>{input}\n{error}</div>"]]); ?> <?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'captcha')->widget(Captcha::className(), ['imageOptions' => ['class' => 'captcha'], 'template' => "<div class='row'><div class='col-lg-4'>{image}</div><div class='col-lg-8'>{input}</div></div>"]); ?> <div class="form-group"> <div class="col-lg-2"></div> <div class="col-lg-7"> <?php echo Html::submitButton('登 录', ['class' => 'btn btn-primary', 'name' => 'login-button']); ?> </div> </div> <?php ActiveForm::end(); ?> </div> </div> </div>
<div id="slide-content2" class="row" style="margin: 0; padding: 0;"> <div class="mail" style=""> <?php echo $form->field($model, 'username', ['inputTemplate' => '{input}', 'inputOptions' => ['id' => 'input-username-check', 'style' => 'margin-bottom: -10px;', 'class' => 'form-control pva-border', 'placeholder' => 'Username']])->label(false); ?> <?php echo $form->field($model, 'email', ['inputTemplate' => '{input}', 'inputOptions' => ['id' => 'input-mail-check', 'style' => 'margin-bottom: -10px;', 'class' => 'form-control pva-border', 'placeholder' => 'Email']])->label(false); ?> <?php echo $form->field($model, 'password', ['inputTemplate' => '{input}', 'inputOptions' => ['id' => 'input-password-check', 'style' => 'margin-bottom: -10px;', 'class' => 'form-control pva-border', 'placeholder' => 'Password']])->passwordInput()->label(false); ?> </div> <div class="vfy" style=""> <?php echo $form->field($model, 'verifyCode')->label(false)->widget(Captcha::className(), ['template' => '<div class="display: inline;"><label class="pull-left" style="color: white;">Captcha Code: </label><div class="text-right">{image}</div><div style="margin-top: 25px; margin-bottom: 25px; color: white;">* * Click image to generate new captcha code</div></div><p></p>{input}']); ?> </div> </div> </div> </div> <div class="slide-btn"> <button type="button" id="btn-info-check" class="btn btn-primary btn-block pva-border" style="height: 46px; background: #337AB7; border: 0;" data-toggle="modal" data-target="#verify">NEXT</button> </div> </div> <p id="msg-info-check" style="color: white; font-size: 16px; margin-top: 20px;"></p> </div> </div> </div> </div> </div>
<div class="form-group"> <?php //echo $form->labelEx($model, 'email'); ?> <?php echo $form->textField($model, 'email', array('class' => 'form-control', 'id' => 'email_txt', 'placeholder' => Yii::t('UserModule.views_auth_recoverPassword', 'your email'))); ?> <?php echo $form->error($model, 'email'); ?> </div> <div class="form-group"> <?php echo \yii\captcha\Captcha::widget(['model' => $model, 'attribute' => 'verifyCode', 'captchaAction' => '/user/auth/captcha', 'options' => array('class' => 'form-control', 'placeholder' => Yii::t('UserModule.views_auth_recoverPassword', 'enter security code above'))]); ?> <?php echo $form->error($model, 'verifyCode'); ?> </div> <hr> <?php echo \humhub\widgets\AjaxButton::widget(['label' => Yii::t('UserModule.views_auth_recoverPassword', 'Reset password'), 'ajaxOptions' => ['type' => 'POST', 'beforeSend' => new yii\web\JsExpression('function(){ setModalLoader(); }'), 'success' => 'function(html){ $("#globalModal").html(html); }', 'url' => Url::to(['/user/password-recovery'])], 'htmlOptions' => ['class' => 'btn btn-primary', 'id' => 'recoverPasswordBtn']]); echo \humhub\widgets\AjaxButton::widget(['label' => Yii::t('UserModule.views_auth_recoverPassword', 'Back'), 'ajaxOptions' => ['type' => 'POST', 'beforeSend' => new yii\web\JsExpression('function(){ setModalLoader(); }'), 'success' => 'function(html){ $("#globalModal").html(html); }', 'url' => Url::to(['/user/auth/login'])], 'htmlOptions' => ['class' => 'btn btn-primary', 'id' => 'backBtn']]); ?> <?php CActiveForm::end(); ?> </div>
<?php echo $form->field($model, 'username'); ?> <?php if ($module->enableGeneratingPassword == false) { ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php } ?> <?php echo $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::className(), ['captchaAction' => ['/site/captcha']]); ?> <?php echo Html::submitButton(Yii::t('user', 'Sign up'), ['class' => 'btn btn-success btn-block']); ?> <?php ActiveForm::end(); ?> </div> </div> <p class="text-center"> <?php echo Html::a(Yii::t('user', 'Already registered? Sign in!'), ['/user/security/login']); ?>
<div class="row"> <div class="col-lg-9"> <?php $form = ActiveForm::begin(['id' => 'form-signup', 'layout' => 'horizontal', 'fieldConfig' => ['template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}", 'horizontalCssClasses' => ['label' => 'col-sm-4', 'offset' => 'col-sm-offset-4', 'wrapper' => 'col-sm-8', 'error' => '', 'hint' => '']]]); ?> <?php echo $form->field($model, 'username')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'email')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'password')->passwordInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['captchaAction' => '/account/captcha', 'imageOptions' => ['alt' => '点击换图', 'title' => '点击换图', 'style' => 'cursor:pointer'], 'template' => '<div class="row"><div class="col-lg-8">{input}</div><div class="col-lg-4">{image}</div></div>']); ?> <div class="form-group"> <div class="col-sm-offset-4 col-sm-9"> <?php echo Html::submitButton('注册', ['class' => 'btn btn-primary', 'name' => 'signup-button']); ?> </div> </div> <?php ActiveForm::end(); ?> </div> </div> </article>
?> <div class="alert alert-warning" role="alert"><?php echo $session->getFlash('resignup'); ?> </div> <?php } ?> <?php echo $form->field($model, 'mobile'); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'captcha')->widget(Captcha::className(), ['template' => "<div class=\"row\">\n<div class=\"col-xs-6\">\n{input}\n</div>\n<div class=\"col-xs-4\">\n{image}\n</div>\n</div>"])->hint('点击验证码换一个。'); ?> <div class="form-group"> <?php echo Html::submitButton('下一步 <i class="fa fa-angle-double-right"></i>', ['class' => 'btn btn-primary btn-fill']); ?> </div> <div class="form-group text-right"> <?php echo Html::a('已有帐号?去登录<i class="fa fa-long-arrow-right"></i>', ['/site/login']); ?> </div> <?php ActiveForm::end(); ?> <?php
?> <?php echo $form->field($model, 'name')->textInput(['size' => 60]); ?> <?php echo $form->field($model, 'email')->textInput(['size' => 60]); ?> <?php echo $form->field($model, 'subject')->textInput(['size' => 60]); ?> <?php echo $form->field($model, 'text')->textarea(['rows' => 10, 'cols' => 80]); ?> <?php echo $form->field($model, 'captcha')->widget(Captcha::className(), ['model' => $model, 'attribute' => 'captcha', 'captchaAction' => '/app/captcha', 'template' => '<div class="cols">{image}</div> <div class="cols">{input}</div>']); ?> <div class="wrap-box-row-submit"> <div class="wrap-box-value"> <?php echo Html::submitButton('Відправити', ['class' => 'buttonOrange', 'name' => 'contact-button']); ?> </div> </div> <?php ActiveForm::end(); ?> <?php
echo Html::activeInput("password", $model, "password", ['placeholder' => "請輸入密碼", "required" => true]); ?> <span>輸入6-12位元英數密碼(不分大小寫)</span> </div> <div class="psw"> <?php echo Html::activeInput("password", $model, "chkpassword", ['placeholder' => "請確認密碼", "required" => true]); ?> <span>確認您的密碼</span> </div> <div class="reload"> <div class="image"> <?php echo $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::className(), ['template' => '<div class="pic">{image}</div>', "imageOptions" => ["style" => "width:60px;height:40px;"]])->label(false)->error(false); ?> </div> <div class="code"> <?php echo Html::activeInput("text", $model, "captcha", ['placeholder' => "請輸入圖形驗證碼", "required" => true, "style" => "padding-left: 70px; padding-right: 0px;"]); ?> </div> <span>請輸入圖形驗證碼</span> </div> <p>如果繼續,即表示同意接受會員條款</p> <button type="submit">註冊</button> <?php ActiveForm::end(); ?> </div>
$form = ActiveForm::begin(['id' => 'contact-form']); ?> <?php echo $form->field($model, 'name')->label('Ваше имя'); ?> <?php echo $form->field($model, 'email')->label('Email'); ?> <?php echo $form->field($model, 'subject')->label('Тема'); ?> <?php echo $form->field($model, 'body')->textArea(['rows' => 6])->label('Сообщение'); ?> <?php echo $form->field($model, 'verifyCode')->hint('Введите код указанный на картинке')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>']); ?> <div class="form-group"> <?php echo Html::submitButton('Отправить', ['class' => 'btn btn-primary', 'name' => 'contact-button']); ?> </div> <?php ActiveForm::end(); ?> </div> </div> <?php } ?>
<!--账号--> <?php echo $form->field($model, 'username', ['inputOptions' => ['placeholder' => '请输入用户名', 'class' => 'input-text size-L'], 'template' => '<div class="row cl"><label class="form-label col-3"><i class="Hui-iconfont"></i></label><div class="formControls col-8">{input}{error}</div></div>'])->textInput(); ?> <!--密码--> <?php echo $form->field($model, 'password', ['inputOptions' => ['placeholder' => '请输入密码', 'class' => 'input-text size-L'], 'template' => '<div class="row cl"><label class="form-label col-3"><i class="Hui-iconfont"></i></label><div class="formControls col-8">{input}{error}</div></div>'])->passwordInput(); ?> <!--验证码--> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row cl"><div class="formControls col-8 col-offset-3" id="verify-div">{image}<span id="imgcode">{input}</span></div></div>', 'imageOptions' => ['alt' => '验证码'], 'captchaAction' => 'login/captcha', 'options' => ['placeholder' => '请输入验证码', 'class' => 'input-text size-L', 'id' => 'verify']]); ?> <!--登陆--> <div class="row"> <div class="formControls col-8 col-offset-3"> <?php echo Html::submitButton('登陆', ['class' => 'btn btn-success radius size-L']); ?> <?php echo Html::resetButton('重置', ['class' => 'btn btn-default radius size-L']); ?> </div> </div>
echo $form->field($model, 'user_loginname'); ?> <?php echo $form->field($model, 'user_password')->passwordInput(); ?> <?php echo $form->field($model, 'verifyPassword')->passwordInput(); ?> <?php echo $form->field($model, 'user_email'); ?> <?php echo $form->field($model, 'verifyEmail'); ?> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['captchaAction' => 'default/captcha', 'options' => ['class' => 'form-control']]); ?> <?php echo Html::submitButton('<i></i><span class="strong">' . \Yii::t('auth.user', 'Sign up') . '</span><span>成为宠嗨网会员</span>', ['class' => 'btn btn-icon-stacked btn-block btn-success glyphicons user_add']); ?> <p><?php echo Html::a(\Yii::t('auth.user', 'Already registered? Sign in!'), ['/auth/default/login']); ?> </p> </div> <?php ActiveForm::end(); ?> <!-- // Form END --> <?php }
/** * Initializes the class map. */ protected function initClassMap() { $this->classMap = ArrayHelper::merge([self::CLASS_ACCOUNT => Account::className(), self::CLASS_TOKEN => AccountToken::className(), self::CLASS_PROVIDER => AccountProvider::className(), self::CLASS_LOGIN_HISTORY => AccountLoginHistory::className(), self::CLASS_PASSWORD_HISTORY => AccountPasswordHistory::className(), self::CLASS_LOGIN_FORM => LoginForm::className(), self::CLASS_PASSWORD_FORM => PasswordForm::className(), self::CLASS_SIGNUP_FORM => SignupForm::className(), self::CLASS_CONNECT_FORM => ConnectForm::className(), self::CLASS_FORGOT_PASSWORD_FORM => ForgotPasswordForm::className(), self::CLASS_WEB_USER => User::className(), self::CLASS_CAPTCHA => Captcha::className(), self::CLASS_CAPTCHA_ACTION => CaptchaAction::className(), self::CLASS_PASSWORD_BEHAVIOR => PasswordAttributeBehavior::className(), self::CLASS_PASSWORD_VALIDATOR => PasswordStrengthValidator::className()], $this->classMap); }
</p> <div class="row"> <div class="col-lg-5"> <?php $form = ActiveForm::begin(['id' => 'contact-form']); ?> <?= $form->field($model, 'name')->label("Nombre") ?> <?= $form->field($model, 'email') ?> <?= $form->field($model, 'subject')->label('Asunto') ?> <?= $form->field($model, 'body')->textArea(['rows' => 6])->label("Cuerpo") ?> <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', ]) ?> <div class="form-group"> <?= Html::submitButton('Enviar', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?> </div> <?php ActiveForm::end(); ?> </div> </div> <?php endif; ?> </div> <br />
<div class="col-sm-7"> <p><?php echo Module::t('site', 'CONTACTS_FORM_INFO'); ?> </p> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'subject'); ?> <?php echo $form->field($model, 'body')->textArea(['rows' => 6]); ?> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['captchaAction' => '/site/default/captcha', 'options' => ['class' => 'form-control'], 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-9">{input}</div></div>']); ?> <?php echo Html::submitButton(Module::t('site', 'CONTACTS_SUBMIT_BTN'), ['class' => 'btn btn-primary btn-lg']); ?> <?php ActiveForm::end(); ?> </div> </div>
if ($group->hidden_group_title == 0) { ?> <h4><?php echo $group->name; ?> </h4> <?php } ?> <?php $properties = Property::getForGroupId($group->id); ?> <?php foreach ($properties as $property) { ?> <?php if ($property->captcha) { echo Captcha::widget(['model' => $model->abstractModel, 'attribute' => $property->key, 'captchaAction' => ['/default/captcha']]); } else { echo $property->handler($form, $model->abstractModel, [], 'frontend_edit_view'); } ?> <?php } ?> <?php } ?> <?php echo \kartik\helpers\Html::submitButton(Yii::t('app', 'Send'), ['class' => 'btn btn-primary']); ActiveForm::end();
echo $form->field($model, 'subject'); ?> </div> </div> <div class="row"> <div class="col-md-12"> <?php echo $form->field($model, 'body')->widget(Redactor::className(), ['clientOptions' => ['imageManagerJson' => ['/redactor/upload/image-json'], 'imageUpload' => ['/redactor/upload/image'], 'fileUpload' => ['/redactor/upload/file'], 'lang' => 'en', 'plugins' => ['clips', 'fontcolor', 'imagemanager']]]); ?> </div> </div> <div class="row"> <div class="col-md-12"> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-md-12 center-blocked">{image}</div><div class="col-md-12">{input}</div></div>']); ?> </div> </div> <div class="form-group text-right"> <?php echo Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']); ?> </div> <?php ActiveForm::end(); ?> </div> <div class="col-md-3"></div> </div>
$form = ActiveForm::begin(['id' => 'contact-form', 'enableAjaxValidation' => false, 'enableClientValidation' => false, 'validateOnSubmit' => false]); ?> <?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'subject'); ?> <?php echo $form->field($model, 'body')->textArea(['rows' => 6]); ?> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['captchaAction' => 'site/captcha', 'template' => '<div class="row"><div class="col-lg-offset-2 col-lg-4">{image}</div><div class="col-lg-6">{input}</div></div>']); ?> <div class="form-group"> <?php echo Html::submitButton(Yii::t('app', 'Submit'), ['class' => 'btn btn-primary', 'name' => 'contact-button']); ?> </div> <?php ActiveForm::end(); ?> </div> </div> <?php } ?>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script src="/static/iadmin/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script> </head> <body id="login"> <div class="container"> <?php $form = \yii\widgets\ActiveForm::begin(['id' => 'loginForm', 'options' => ['class' => 'form-signin']]); ?> <h2 class="form-signin-heading">后台登陆</h2> <input type="text" name="WAdmin[username]" id="username" class="input-block-level" placeholder="用户名"> <input type="password" name="WAdmin[password]" id="password" class="input-block-level" placeholder="密码"> <?php echo $form->field($model, 'verifycode')->widget(\yii\captcha\Captcha::className(), ['options' => ['placeholder' => '验证码'], 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>'])->label(''); ?> <label class="checkbox"> <input type="checkbox" name="WAdmin[reme]" value="1"> 记住我 </label> <button class="btn btn-large btn-primary" id="loginBtn" type="button">登陆</button> <?php \yii\widgets\ActiveForm::end(); ?> </div> <!-- /container --> <script src="/static/iadmin/vendors/jquery-1.9.1.min.js"></script> <script src="/static/iadmin/bootstrap/js/bootstrap.min.js"></script> <script type="text/javascript"> $(function () { $('#loginBtn').on('click', function () { $.post('<?php
<div id="comment_send_form_bottom_box"> <div class="" style="margin-top: 10px;" id="comment_send_form_box"> <div class="panel panel-default"> <div class="panel-body"> <p><strong>Написать комментарий:</strong></p> <?php $form = ActiveForm::begin(['id' => 'comment-form', 'options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'text')->textArea(['rows' => 3])->label('Текст:'); ?> <?php echo $form->field($model, 'file')->fileInput()->label('Прикрепить изображение:'); ?> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => ' <div style=""> <div style="float: left">{image}</div> <div style="width: 120px; float: left">{input} </div> </div>'])->label('Капча:'); ?> <?php echo $form->field($model, 'post_id')->hiddenInput()->label(false); ?> <?php echo $form->field($model, 'parent_id')->hiddenInput()->label(false); ?> <input type="hidden" name=""> <div class="form-group">
<?php echo $form->field($fileModel, 'files[]')->fileInput(['multiple' => true]); ?> </div> </div> <div class="row"> <div class="col-md-8"> <p>Let op! Door de verificatie code in te vullen en op aanmelden te klikken, gaat u akkoord met onze <a href="<?php echo Url::toRoute('/site/page/algemene-voorwaarden'); ?> ">algemene voorwaarden</a>.</p> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['captchaAction' => '/incasso/default/captcha', 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>']); ?> </div> </div> <div class="row"> <div class="col-md-8"> <div class="form-group"> <?php echo Html::submitButton('Aanmelden', ['class' => 'btn btn-primary', 'name' => 'contact-button']); ?> </div> </div> </div> </div>
</div> <?php } ?> <div class="uk-width-medium-4-10 uk-form-row"> <?php echo $form->field($respond, 'author')->textInput(['class' => 'uk-width-large', 'placeholder' => 'Имя'])->label(false); ?> <?php echo $form->field($respond, 'email')->textInput(['class' => 'uk-width-large', 'placeholder' => 'E-mail'])->label(false); ?> </div> <div class="uk-width-medium-2-10 uk-form-row"> <div id="captcha"> <?php echo $form->field($respond, 'captcha')->widget(Captcha::className(), ['captchaAction' => '/comments/captcha'])->label(false); ?> </div> </div> <?php } ?> <div class="uk-width-medium-4-10 uk-form-row"> <?php echo Html::submitButton('Отправить комментарий', ['class' => 'uk-width-1-1 uk-button uk-button-success']); ?> </div> <div class="uk-width-medium-4-10 uk-form-row"> <a class="dfn uk-hidden" href="#respond" data-reply-main>в новой ветке</a> </div> </div>
/** * Renders the CAPTCHA image. * @param string $code the verification code * @return string image contents */ protected function renderImage($code) { if (Captcha::checkRequirements() === 'gd') { return $this->renderImageByGD($code); } else { return $this->renderImageByImagick($code); } }
?> <?php echo $form->field($model, 'email')->label('邮箱'); ?> <?php echo $form->field($model, 'password')->label('密码')->passwordInput()->hint('最短6位,区分大小写'); ?> <?php echo $form->field($model, 'passwordRepeat')->label('确认密码')->passwordInput()->hint('再次输入密码'); ?> <?php echo $form->field($model, 'verifyCode')->label('验证码')->Widget(Captcha::className(), ['template' => '{input}{image}' . Html::tag('a', '换一张', ['id' => 'link-captcha-change']), 'options' => ['class' => 'form-control verify-code'], 'imageOptions' => ['id' => 'captcha-img', 'alt' => '验证码'], 'captchaAction' => '/support/captcha']); ?> <?php echo $form->field($model, 'isAgree')->label('我同意并遵守', ['class' => 'control-label col-md-offset-2'])->checkbox(['template' => '<div class="checkbox">{beginLabel}{input}{labelTitle}{endLabel}<a href="#">《动动场馆服务协议》</a></div>']); ?> <div class="form-group"> <span class="col-md-offset-3"> <?php echo Html::submitButton('', ['class' => 'reg-button', 'name' => 'submit']); ?> </span> </div> <?php
<?php $form = ActiveForm::begin(['id' => 'contact-form']); ?> <?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'subject'); ?> <?php echo $form->field($model, 'body')->textArea(['rows' => 6]); ?> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>']); ?> <div class="form-group"> <?php echo Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']); ?> </div> <?php ActiveForm::end(); ?> </div> </div> </div>
<p>Please fill out the following fields to login:</p> <?php $form = ActiveForm::begin(['id' => 'login-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label']]]); ?> <?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'captcha')->widget(Captcha::className()); ?> <?php echo $form->field($model, 'rememberMe', ['template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>"])->checkbox(); ?> <div class="form-group"> <div class="col-lg-offset-1 col-lg-11"> <?php echo Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']); ?> </div> </div> <?php