当前位置: 首页>>代码示例>>PHP>>正文


PHP widgets\ActiveForm类代码示例

本文整理汇总了PHP中kartik\widgets\ActiveForm的典型用法代码示例。如果您正苦于以下问题:PHP ActiveForm类的具体用法?PHP ActiveForm怎么用?PHP ActiveForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ActiveForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUpdate

 /**
  * Updates an existing Questionnaire model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (\Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         \Yii::$app->response->format = 'json';
         return \kartik\widgets\ActiveForm::validate($model);
     }
     $persondetails = \app\models\Participant::findOne(['pk_person' => $model->fk_person]);
     if ($model->load(Yii::$app->request->post())) {
         $model->creation_name = Yii::$app->user->identity->username;
         $model->altered = 1;
         $persondetails->filtered = $persondetails->filtered + 1;
         $model->hbp_med_list = $_POST['Questionnaire']['enalapril'] . "," . $_POST['Questionnaire']['atenolol'] . ", " . $_POST['Questionnaire']['propranolol'] . "," . $_POST['Questionnaire']['hydrochlorthiazide'] . "," . $_POST['Questionnaire']['frusemide'] . "," . $_POST['Questionnaire']['aldactone'] . "," . $_POST['Questionnaire']['methyldopa'] . "," . $_POST['Questionnaire']['nifedipine'] . "," . $_POST['Questionnaire']['hydralazine'];
         if ($_POST['Questionnaire']['own_none'] == 1) {
             $model->household_own = "0,0,0,0,0,0,1";
         } else {
             $model->household_own = $_POST['Questionnaire']['car'] . "," . $_POST['Questionnaire']['refridgerator'] . ", " . $_POST['Questionnaire']['bicycle'] . "," . $_POST['Questionnaire']['radio'] . "," . $_POST['Questionnaire']['television'] . "," . $_POST['Questionnaire']['own_none'];
         }
         $persondetails->filtered = 1;
         if ($model->save(FALSE) && $persondetails->save(FALSE)) {
             Yii::$app->session->setFlash('success', 'The questionnaire saved successfully');
             return $this->redirect(['participant/apptmnts']);
         }
     } else {
         return $this->render('update', ['model' => $model, 'persondetails' => $persondetails]);
     }
 }
开发者ID:jibendi,项目名称:shinda2,代码行数:33,代码来源:QuestionnaireController.php

示例2: init

 /**
  * 初始化
  */
 public function init()
 {
     Yii::$container->set('yii\\widgets\\LinkPager', ['firstPageLabel' => '首页', 'lastPageLabel' => '尾页', 'prevPageLabel' => '上页', 'nextPageLabel' => '下页', 'hideOnSinglePage' => false, 'options' => ['class' => 'pagination pull-right']]);
     Yii::$container->set('yii\\data\\Pagination', ['defaultPageSize' => 15]);
     Yii::$container->set('yii\\grid\\ActionColumn', ['template' => '{update} {delete}']);
     Yii::$container->set(ActiveForm::className(), ['type' => ActiveForm::TYPE_HORIZONTAL]);
     Yii::$container->set('yii\\captcha\\Captcha', ['captchaAction' => 'home/captcha']);
     Yii::$container->set('yii\\captcha\\CaptchaValidator', ['captchaAction' => 'home/captcha']);
     Yii::$container->set('backend\\behaviors\\TestBehavior', ['msg' => 'xxxxxxx']);
 }
开发者ID:tqsq2005,项目名称:yga,代码行数:13,代码来源:BackendController.php

示例3: run

 /**
  * @inheritdoc
  * @param int $id
  * @return int|mixed
  * @throws NotFoundHttpException
  */
 public function run($id)
 {
     /** @var Form|HasProperties $form */
     if (null === ($form = Form::findById($id))) {
         throw new NotFoundHttpException();
     }
     $post = Yii::$app->request->post();
     $form->abstractModel->setAttrubutesValues($post);
     /** @var AbstractModel|SpamCheckerBehavior $model */
     $model = $form->getAbstractModel();
     if (Yii::$app->request->isAjax && isset($post['ajax'])) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     /** @var \app\models\Object $object */
     $object = Object::getForClass(Form::className());
     $propGroups = ObjectPropertyGroup::find()->where(['and', 'object_id = :object', 'object_model_id = :id'], [':object' => $object->id, ':id' => $id])->asArray()->all();
     $propIds = ArrayHelper::getColumn($propGroups, 'property_group_id');
     // Spam checking
     $activeSpamChecker = SpamChecker::getActive();
     $data = [];
     $haveSpam = false;
     if ($activeSpamChecker !== null && !empty($activeSpamChecker->api_key)) {
         $data[$activeSpamChecker->name]['class'] = $activeSpamChecker->behavior;
         $data[$activeSpamChecker->name]['value']['key'] = $activeSpamChecker->api_key;
         $properties = Property::getForGroupId($propIds[0]);
         foreach ($properties as $prop) {
             if (!isset($activeSpamChecker->{$prop->interpret_as}) || empty($activeSpamChecker->{$prop->interpret_as})) {
                 continue;
             }
             $data[$activeSpamChecker->name]['value'][$activeSpamChecker->{$prop->interpret_as}] = is_array($post[$form->abstractModel->formName()][$prop->key]) ? implode(' ', $post[$form->abstractModel->formName()][$prop->key]) : $post[$form->abstractModel->formName()][$prop->key];
         }
         $model->attachBehavior('spamChecker', ['class' => SpamCheckerBehavior::className(), 'data' => $data]);
         $haveSpam = $model->isSpam();
     }
     $date = new \DateTime();
     /** @var Submission|HasProperties $submission */
     $submission = new Submission(['form_id' => $form->id, 'date_received' => $date->format('Y-m-d H:i:s'), 'ip' => Yii::$app->request->userIP, 'user_agent' => Yii::$app->request->userAgent, 'spam' => (int) $haveSpam]);
     if (false === Yii::$app->user->isGuest) {
         $submission->processed_by_user_id = Yii::$app->user->identity->getId();
     }
     if (!($form->abstractModel->validate() && $submission->save())) {
         return "0";
     }
     if (isset($post[$form->abstractModel->formName()])) {
         $data = ['AddPropetryGroup' => [$submission->formName() => array_keys($form->getPropertyGroups())], $submission->abstractModel->formName() => $post[$form->abstractModel->formName()]];
         if (isset($_FILES[$form->abstractModel->formName()])) {
             $_FILES[$submission->abstractModel->formName()] = $_FILES[$form->abstractModel->formName()];
         }
         $submission->saveProperties($data);
     }
     return $submission->id;
 }
开发者ID:xuantienvp,项目名称:dotplant2,代码行数:59,代码来源:SubmitFormAction.php

示例4: run

 public function run()
 {
     $form = ActiveForm::begin($this->formOptions);
     $column = [];
     $options = $this->attributeOptions;
     if (!isset($options['fieldConfig'])) {
         $options['fieldConfig'] = [];
     }
     if (!isset($options['fieldConfig']['template'])) {
         $options['fieldConfig']['template'] = "{input}\n{hint}\n{error}";
     }
     switch ($this->type) {
         case EditableType::TYPE_TEXT:
             $column[$this->attribute] = ExtForm::textField($options);
             break;
     }
     echo Form::widget(['model' => $this->model, 'form' => $form, 'attributes' => $column]);
     ActiveForm::end();
 }
开发者ID:hanterrian,项目名称:field-extensions,代码行数:19,代码来源:FormWidget.php

示例5:

<?php

use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\widgets\ActiveField;
use yii\helpers\ArrayHelper;
use yii\web\Session;
use yii\bootstrap\Modal;
/* @var $this yii\web\View */
/* @var $model frontend\models\Presentations */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="presentations-search" style="margin-top:10px; margin-bottom:10px;">
<?php 
$form = kartik\widgets\ActiveForm::begin(['id' => 'form-horizontal-presentation-search', 'action' => ['index'], 'method' => 'get', 'type' => ActiveForm::TYPE_VERTICAL]);
?>
    <h4 class="gray-color">Filteri pretrage
    <div class="float-right"><?php 
echo Html::resetButton(Yii::t('app', '<i class="fa fa-stop-circle"></i> Resetuj filtere'), ['class' => 'btn btn-link']);
?>
        <?php 
echo Html::button(Yii::t('app', '<i class="fa fa-undo"></i> Poništi sve filtere'), ['class' => 'btn btn-link', 'name' => 'clear', 'onclick' => 'clearForm(this.form);']);
?>
        </div>
    </h4>
    <fieldset class="settings mini">
    <?php 
echo $this->render('searchParts/title.php', ['form' => $form, 'model' => $model, 'service' => $service]);
?>

    <?php 
开发者ID:bokko79,项目名称:servicemapp,代码行数:31,代码来源:_filters.php

示例6:

<?php

/**
 *	  ┏┓   ┏┓
 *	┏┛┻━━━┛┻┓
 *	┃       ┃
 *	┃   ━   ┃
 *	┃ ┳┛ ┗┳ ┃
 *	┃       ┃
 *	┃   ┻   ┃
 *	┃       ┃
 *	┗━┓   ┏━┛
 *	    ┃   ┃   神兽保佑
 *	    ┃   ┃   代码无BUG!
 *	 	 ┃   ┗━━━┓
 *	    ┃       ┣┓
 *	    ┃       ┏┛
 *	    ┗┓┓┏━┳┓┏┛
 *	      ┃┫┫ ┃┫┫
 *	      ┗┻┛ ┗┻┛
 */
use kartik\widgets\ActiveForm;
$form = ActiveForm::begin(['id' => 'userform']);
echo $form->field($model, 'username')->textInput();
echo $form->field($model, 'password')->passwordInput();
echo $form->field($model, 'password_repeat')->passwordInput();
$form->end();
开发者ID:tqsq2005,项目名称:yga,代码行数:27,代码来源:loadhtml.php

示例7: actionCheckcustomeruniquecode

 /**
  *Check customer code is unique // use with Active form and field ajax validation
  */
 public function actionCheckcustomeruniquecode()
 {
     if (Yii::$app->request->isAjax) {
         $model = new Customer();
         if ($model->load(Yii::$app->request->post())) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     } else {
         throw new NotFoundHttpException();
     }
 }
开发者ID:hoangec,项目名称:hocyii2,代码行数:15,代码来源:CustomerController.php

示例8:

<?php

use kartik\icons\Icon;
use kartik\widgets\ActiveForm;
use kartik\widgets\Select2;
use yii\helpers\Html;
?>
<div class="well">
    <?php 
echo $this->render('alert');
?>
    <?php 
$form = ActiveForm::begin(['id' => 'DatabaseChoose', 'action' => \yii\helpers\Url::to(['']), 'type' => ActiveForm::TYPE_HORIZONTAL, 'enableClientScript' => false, 'enableClientValidation' => true, 'options' => ['onkeypress' => "return event.keyCode != 13;"]]);
echo $form->errorSummary($model, ['class' => 'alert alert-danger']);
?>
    <?php 
echo $form->field($model, 'type')->widget(Select2::classname(), ['data' => $model->getTypes(), 'options' => ['placeholder' => $model->getAttributeLabel('type'), 'name' => 'DatabaseChoose[type]'], 'pluginOptions' => ['allowClear' => false, 'minimumResultsForSearch' => '-1']]);
?>
    <?php 
echo \yii\bootstrap\Button::widget(['id' => 'backButton', 'label' => Icon::show('arrow-circle-left') . Yii::t('install', 'Back'), 'encodeLabel' => false, 'options' => ['class' => 'btn btn-info', 'onClick' => new \yii\web\JsExpression("\n            \$('#stepsMenu a:eq({$previousStep})').click();\n            return false;")]]);
echo Html::a(Icon::show('arrow-circle-right') . Yii::t('install', 'Continue'), '', ['class' => 'btn btn-info', 'style' => 'margin-left: 10px;', 'onClick' => new \yii\web\JsExpression("\n        \$('#DatabaseChoose').submit();\n        return false;")]);
?>
</div>
开发者ID:fourteenmeister,项目名称:yii2-install,代码行数:23,代码来源:step-3.php

示例9: run

 /**
  * @param int $id
  * @return int|mixed
  * @throws NotFoundHttpException
  */
 public function run($id)
 {
     /** @var Form|HasProperties $form */
     if (null === ($form = Form::findById($id))) {
         throw new NotFoundHttpException();
     }
     $post = \Yii::$app->request->post();
     $form->abstractModel->setAttrubutesValues($post);
     /** @var AbstractModel|SpamCheckerBehavior $model */
     $model = $form->getAbstractModel();
     if (\Yii::$app->request->isAjax && isset($post['ajax'])) {
         \Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     /** @var \app\models\Object $object */
     $object = Object::getForClass(Form::className());
     $propGroups = ObjectPropertyGroup::find()->where(['and', 'object_id = :object', 'object_model_id = :id'], [':object' => $object->id, ':id' => $id])->asArray()->all();
     $propIds = ArrayHelper::getColumn($propGroups, 'property_group_id');
     // Spam checking
     $activeSpamChecker = SpamChecker::getActive();
     $data = [];
     $spamResult = [];
     if ($activeSpamChecker !== null && !empty($activeSpamChecker->api_key)) {
         $data[$activeSpamChecker->name]['class'] = $activeSpamChecker->behavior;
         $data[$activeSpamChecker->name]['value']['key'] = $activeSpamChecker->api_key;
         $properties = Property::getForGroupId($propIds[0]);
         foreach ($properties as $prop) {
             if (!isset($activeSpamChecker->{$prop->interpret_as}) || empty($activeSpamChecker->{$prop->interpret_as})) {
                 continue;
             }
             $data[$activeSpamChecker->name]['value'][$activeSpamChecker->{$prop->interpret_as}] = is_array($post[$form->abstractModel->formName()][$prop->key]) ? implode(' ', $post[$form->abstractModel->formName()][$prop->key]) : $post[$form->abstractModel->formName()][$prop->key];
         }
         $model->attachBehavior('spamChecker', ['class' => SpamCheckerBehavior::className(), 'data' => $data]);
         $spamResult = $model->check();
     }
     $haveSpam = false;
     if (is_array($spamResult) === true) {
         foreach ($spamResult as $result) {
             if (ArrayHelper::getValue($result, 'ok', false) === true) {
                 $haveSpam = $haveSpam || ArrayHelper::getValue($result, 'is_spam', false);
             }
         }
     }
     $date = new \DateTime();
     /** @var Submission|HasProperties $submission */
     $submission = new Submission(['form_id' => $form->id, 'date_received' => $date->format('Y-m-d H:i:s'), 'ip' => Yii::$app->request->userIP, 'user_agent' => Yii::$app->request->userAgent, 'spam' => (int) $haveSpam]);
     if (false === Yii::$app->user->isGuest) {
         $submission->processed_by_user_id = Yii::$app->user->identity->getId();
     }
     if (!($form->abstractModel->validate() && $submission->save())) {
         return "0";
     }
     if (isset($post[$form->abstractModel->formName()])) {
         $data = ['AddPropetryGroup' => [$submission->formName() => array_keys($form->getPropertyGroups())], $submission->abstractModel->formName() => $post[$form->abstractModel->formName()]];
         if (isset($_FILES[$form->abstractModel->formName()])) {
             $_FILES[$submission->abstractModel->formName()] = $_FILES[$form->abstractModel->formName()];
         }
         $submission->saveProperties($data);
     }
     if ($haveSpam === false) {
         if (!empty($form->email_notification_addresses)) {
             try {
                 $emailView = !empty($form->email_notification_view) ? $form->email_notification_view : '@app/widgets/form/views/email-template.php';
                 Yii::$app->mail->compose($emailView, ['form' => $form, 'submission' => $submission])->setTo(explode(',', $form->email_notification_addresses))->setFrom(Yii::$app->mail->getMailFrom())->setSubject($form->name . ' #' . $submission->id)->send();
             } catch (\Exception $e) {
                 // do nothing
             }
         }
     }
     return $submission->id;
 }
开发者ID:keyeMyria,项目名称:dotplant2,代码行数:76,代码来源:SubmitFormAction.php

示例10:

<?php 
echo $form->field($model, 'out_account_id')->dropDownList($persons);
?>

<?php 
echo $form->field($model, 'in_account_id')->dropDownList($me);
?>

<?php 
echo $form->field($model, 'create_time')->widget('kartik\\widgets\\DateTimePicker');
?>

<?php 
echo $form->field($model, 'over_time')->widget('kartik\\widgets\\DatePicker', ['pluginOptions' => ['format' => 'yyyy-m-d']]);
?>

<?php 
echo $form->field($model, 'description')->textInput();
?>

<?php 
echo Html::submitButton('Create', ['class' => 'btn btn-success']);
?>

<?php 
$form = ActiveForm::end();
?>

<?php 
echo Html::a('返回', '/index.php?r=fund/currency/index');
开发者ID:jh27408079,项目名称:magenet,代码行数:30,代码来源:borrow.php

示例11: foreach

    }
    ?>
    <?php 
    $properties = \app\models\Property::getForGroupId($group->id);
    ?>
    <?php 
    foreach ($properties as $property) {
        ?>
        <?php 
        echo $property->handler($form, $model->abstractModel, [], 'frontend_edit_view');
        ?>
    <?php 
    }
}
echo Html::submitButton(Yii::t('app', 'Send'), ['class' => 'btn btn-primary']);
\kartik\widgets\ActiveForm::end();
\yii\bootstrap\Modal::end();
?>

<?php 
$js = <<<JS
    "use strict";
    \$('#orderchat-message').keypress(function (event) {
        if (event.keyCode == 10) {
            \$(this).parents('form').eq(0).submit();
        }
    });
    \$('body').on('editableSuccess', function () {
        location.reload();
    });
    \$('#print-button').click(function () {
开发者ID:Razzwan,项目名称:dotplant2,代码行数:31,代码来源:view.php

示例12: join

use yii\helpers\ArrayHelper;
use kartik\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\Bank */
$this->title = 'Platzhalter für:';
$this->params['breadcrumbs'][] = ['label' => 'Banken', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$model = new \app\models\Alias();
?>
<div class="bank-view">
	<h4><?php 
echo join(', ', ArrayHelper::map($banks, 'b_id', 'bezeichnung'));
?>
</h4>
	<?php 
$form = ActiveForm::begin(['method' => 'post']);
?>
		<table class="table table-bordered">
			<tr>
				<th>Platzhalter</th>
				<th>Ersetzen durch</th>
				<th>Funktionen</th>
			</tr>
			<?php 
foreach ($aliases as $key => $alias) {
    ?>
				<?php 
    if ($alias['cnt'] == count($banks)) {
        ?>

					<tr>
开发者ID:emotionbanker,项目名称:emotionbanking,代码行数:31,代码来源:alias.php

示例13:

<?php

use yii\helpers\Html;
use yii\helpers\Url;
use kartik\widgets\ActiveForm;
use kartik\widgets\ActiveField;
use yii\helpers\ArrayHelper;
?>

<div class="container-fluid">
	<div class="row">
		<div class="col-md-12">	
		<?php 
$form = kartik\widgets\ActiveForm::begin(['id' => 'form-vertical', 'method' => 'get', 'type' => ActiveForm::TYPE_VERTICAL]);
?>
			<?php 
if ($service->object_ownership == 'user') {
    ?>
				<p class="hint">Možete izabrati više vrsta.</p>
				<div class="enclosedCheckboxes">
					<div class="checkbox"><label><input type="checkbox" id="ckbCheckAll<?php 
    echo $service->id;
    ?>
"> <i>Izaberite/Poništite sve</i></label></div>
					<?php 
    echo $form->field($model, 'object_models[]')->checkboxList($service->objectModelsList, ['unselect' => null, 'class' => 'column3 multiselect'])->label(false);
    ?>
				</div>
			<?php 
} else {
    ?>
开发者ID:bokko79,项目名称:servicemapp,代码行数:31,代码来源:presentation-oms.php

示例14:

 *        ┃   ┃   代码无BUG!
 *         ┃   ┗━━━┓
 *        ┃       ┣┓
 *        ┃       ┏┛
 *        ┗┓┓┏━┳┓┏┛
 *          ┃┫┫ ┃┫┫
 *          ┗┻┛ ┗┻┛
 */
use kartik\widgets\ActiveForm;
use yii\helpers\Url;
use yii\helpers\Html;
?>

<div class="col-lg-6">
    <?php 
$form = ActiveForm::begin(['validationUrl' => Url::toRoute(['rbac/validateitemname'])]);
?>

    <?php 
echo $form->field($model, 'name', ['enableAjaxValidation' => true])->textInput();
?>
    <?php 
echo $form->field($model, 'description')->textarea();
?>
    <?php 
echo Html::hiddenInput('id', $model->name);
?>

    <div class="form-group center">
        <?php 
echo Html::submitButton('提交', ['class' => 'btn btn-lg btn-primary']);
开发者ID:tqsq2005,项目名称:yga,代码行数:31,代码来源:_form.php

示例15: actionCreateAjax

 public function actionCreateAjax($selector = 'selectorPersonas')
 {
     // si no se especifica el parametro $selector se toma 'selectorPersonas' por defecto, esto comportamiento contempla
     // el caso de que en el mismo form se use mas de un select2 para buscar personas (por ejemplo personas/change)
     $model = new Personas();
     $model->id_tipo_doc = 96;
     // DNI por defecto
     $model->estado = Personas::ESTADO_ACTIVO;
     // Al estar habilitado la validation ajax, $_POST['ajax'] viene seteado, si vino por el submit, esta variable no existe
     // Siempre se devuelve el validate
     if (isset($_POST['ajax'])) {
         Yii::$app->response->format = 'json';
         $model->load(Yii::$app->request->post());
         return ActiveForm::validate($model);
     }
     // si no viene seteado $_POST['ajax'] se asume que se entro por el submit
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             Yii::$app->response->format = 'json';
             return ['modelP' => $model];
         } else {
             Yii::$app->response->format = 'json';
             return ActiveForm::validate($model);
         }
     }
     return $this->renderAjax('createajax', ['model' => $model, 'selector' => $selector]);
 }
开发者ID:ibergonzi,项目名称:country,代码行数:27,代码来源:PersonasController.php


注:本文中的kartik\widgets\ActiveForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。