本文整理汇总了PHP中yii\bootstrap\ActiveForm::begin方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveForm::begin方法的具体用法?PHP ActiveForm::begin怎么用?PHP ActiveForm::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\ActiveForm
的用法示例。
在下文中一共展示了ActiveForm::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* @param array $config
* @return string
*/
public static function generate($config = [])
{
$reservedAttributeNames = ['plainHTML'];
ob_start();
$form = ActiveForm::begin($config['formConfig']);
foreach ($config['fields'] as $attribute => $fieldConfig) {
if (in_array($attribute, $reservedAttributeNames)) {
echo $fieldConfig;
} else {
if (isset($fieldConfig['render'])) {
$render = $fieldConfig['render'];
switch ($render['type']) {
case 'inline':
$method = $render['method'];
$options = isset($render['options']) ? $render['options'] : [];
echo $form->field($fieldConfig['model'], $attribute, isset($fieldConfig['options']) ? $fieldConfig['options'] : [])->{$method}($options);
break;
case 'widget':
$class = $render['class'];
$options = isset($render['options']) ? $render['options'] : [];
echo $form->field($fieldConfig['model'], $attribute, isset($fieldConfig['options']) ? $fieldConfig['options'] : [])->widget($class, $options);
break;
}
} else {
echo $form->field($fieldConfig['model'], $attribute, isset($fieldConfig['options']) ? $fieldConfig['options'] : []);
}
}
}
ActiveForm::end();
$result = ob_get_contents();
ob_end_clean();
return $result;
}
示例2: run
/**
* @inheritdoc
*/
public function run()
{
$form = ActiveForm::begin();
echo $form->errorSummary($this->commentModel);
echo $form->field($this->commentModel, 'title')->textInput(['maxlength' => true]);
echo $form->field($this->commentModel, 'content')->textarea($this->textAreaOptions);
echo Html::submitButton(empty($this->buttonLabel) ? Yii::t('app', 'Save') : $this->buttonLabel, $this->buttonOptions);
ActiveForm::end();
}
示例3: run
public function run()
{
parent::run();
$model = new \app\models\ProjectSimpleForm();
$form = ActiveForm::begin(['id' => 'project-simple-form', 'action' => ['/project/simplecreate'], 'layout' => 'inline', 'validateOnChange' => false, 'validateOnBlur' => false]);
echo $form->field($model, 'title')->textInput(['maxlength' => 255, 'class' => 'form-control input-sm'])->label(false);
echo '<div class="form-group">' . Html::submitButton(Yii::t('app', 'Create'), ['class' => 'btn btn-sm btn-success', 'style' => 'margin: 5px 5px 5px 0;']) . Html::resetButton(Yii::t('app', 'Cancel'), ['class' => 'btn btn-xs', 'style' => 'margin: 5px;']) . '</div>';
ActiveForm::end();
$this->registerJs();
}
示例4: api_form
public function api_form($options = [])
{
$model = new Subscriber();
$options = array_merge($this->_defaultFormOptions, $options);
ob_start();
$form = ActiveForm::begin(['enableAjaxValidation' => true, 'action' => Url::to(['/admin/subscribe/send']), 'layout' => 'inline']);
echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0]));
echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1]));
echo $form->field($model, 'email')->input('email', ['placeholder' => 'E-mail']);
echo Html::submitButton(Yii::t('easyii/subscribe/api', 'Subscribe'), ['class' => 'btn btn-primary', 'id' => 'subscriber-send']);
ActiveForm::end();
return ob_get_clean();
}
示例5: run
public function run()
{
$formId = $this->formOptions['id'];
$this->getView()->registerCss("#{$formId} button {-webkit-box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.2);box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.2);}");
$form = ActiveForm::begin(array_merge($this->defaultFormOptions, $this->formOptions));
print Html::beginTag('div', ['class' => 'row']);
print Html::beginTag('div', ['class' => 'col-xs-12']);
print Html::beginTag('div', ['class' => 'input-group']);
if ($this->inputWidget) {
print $form->field($this->model, $this->attribute, ['template' => '{input}'])->widget($this->inputWidget, $this->inputOptions);
} else {
print $form->field($this->model, $this->attribute, ['template' => '{input}'])->input($this->inputType, array_merge(['placeholder' => $this->model->getAttributeLabel($this->attribute), 'class' => 'form-control'], $this->inputOptions));
}
print Html::beginTag('span', ['class' => 'input-group-btn']);
print Html::submitButton(Yii::t('hipanel', 'Search'), ['class' => 'btn btn-flat ' . $this->buttonColor]);
print Html::endTag('span');
print Html::endTag('div');
print Html::endTag('div');
print Html::endTag('div');
ActiveForm::end();
}
示例6:
<input id="' . $index . '_' . $name . '" type="checkbox" name="' . $name . '" value="' . $value . '" ' . $seleccion . '>
<label for="' . $index . '_' . $name . '">' . $label . '</label>
</div>';
return $html;
}, 'itemOptions' => ['labelOptions' => []]];
$inputClase = 'form-control input-md';
$inputReadClase = 'form-control form-control-static';
$articulo = $model->cargarArticulo();
$listadoImagenes = Yii::$app->controller->action->id != 'publicar' ? ImagenHelper::listaImagenesString($articulo->archivos) : [];
$ImagenPrincipal = Yii::$app->controller->action->id != 'publicar' ? $articulo->obtenerPosicionImagenPrincipal() : 0;
$session = Yii::$app->session;
?>
<?php
$form = ActiveForm::begin(['id' => 'articulo', "enableClientValidation" => false, 'enableAjaxValidation' => false, 'validateOnChange' => false, 'options' => ['validateOnSubmit' => true, 'enctype' => 'multipart/form-data', 'class' => 'enviarForm form', 'role' => 'form'], 'fieldConfig' => ['template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}", 'hintOptions' => ['tag' => 'span'], 'errorOptions' => ['tag' => 'span'], 'horizontalCssClasses' => ['label' => 'col-sm-3', 'offset' => 'col-sm-offset-3', 'wrapper' => 'col-sm-9', 'error' => 'error-block', 'hint' => 'help-block']]]);
?>
<!-- BEGIN CONTENIDO -->
<div class="row">
<div class="col-md-12">
<div class="card-box">
<?php
echo Html::activeHiddenInput($model, 'idarticulo');
?>
<div class="row">
<div class="col-xs-12">
<?php
echo DropZone::widget(['subirUrl' => Yii::$app->urlManager->createUrl('addimagenes'), 'eliminarUrl' => Yii::$app->urlManager->createUrl('delimagenes'), 'textoContenedor' => 'Arrastra aquí tus fotos. Puedes subir varias a la vez', 'iconContenedor' => 'zmdi zmdi-image', 'initImagenes' => $listadoImagenes, 'initImagenPrincipal' => $ImagenPrincipal, 'maxImagenes' => 4, 'options' => ['maxFilesize' => '2']]);
示例7:
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use dosamigos\ckeditor\CKEditorInline;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $model backend\models\BgForm */
/* @var $form ActiveForm */
?>
<div class="site-bgform">
<?php
$form = ActiveForm::begin(['options' => ['data-pjax' => '1'], 'id' => 'bg-form']);
?>
<div>
<?php
$model->setDir();
$model->BgForm();
foreach ($model->dir as $value) {
echo '<div>';
echo '<div class="col-sm-3"><a href="./uploads/' . $value . '"><IMG src="./uploads/' . $value . '" class = "img" WIDTH="100%" HEIGHT="200px" align="left" >';
//echo substr($value, -12); //сокращаем изображаемое название на 12 символов
echo '</a>';
echo $form->field($model, 'value[]')->radio(['value' => $value]);
echo '</div>';
echo '</div>';
}
?>
示例8:
});
JS
);
?>
</div>
</div>
<div id="blockOrder"<?php
if (Yii::$app->user->isGuest) {
echo ' style="display: none;"';
}
?>
>
<?php
$model = new \app\models\Form\Shop\Request();
$form = \yii\bootstrap\ActiveForm::begin(['id' => 'contact-form', 'options' => ['enctype' => 'multipart/form-data'], 'enableClientScript' => false]);
?>
<?php
echo $model->field($form, 'dostavka')->radioList(\app\models\Shop\Request::$dostavkaList);
?>
<?php
echo $model->field($form, 'address')->textarea(['rows' => 3]);
?>
<?php
echo $model->field($form, 'phone');
?>
<?php
echo $model->field($form, 'comment')->textarea(['rows' => 3]);
?>
<?php
\yii\bootstrap\ActiveForm::end();
示例9: foreach
}
/*$countries = Category::findOne(['name' => $menu->name]);
$leaves = $countries->leaves()->all();
foreach ($leaves as $children) {
echo $children->name;
}*/
}
echo '</ul>';
echo '</div>';
?>
</div>
<div class="col-sm-8">
<?php
$form = ActiveForm::begin(['id' => 'create_category', 'action' => ['/category/create']]);
echo $form->field($model, 'parent')->textInput()->label('Parents');
echo $form->field($model, 'name')->textInput();
echo "<button class='btn btn-primary'>Save</button>";
ActiveForm::end();
?>
</div>
</div>
<?php
/*$countries = Category::find()->where(['name' => 'Countries'])->roots()->all();
//$parent = $countries->parents()->all();
foreach ($countries as $test) {
echo $test['name'];
}
示例10: function
?>
<?php
echo GridView::widget(['dataProvider' => $tourGames[$tour], 'responsive' => false, 'hover' => true, 'showPageSummary' => true, 'responsiveWrap' => false, 'export' => false, 'bordered' => false, 'showHeader' => false, 'caption' => "Тур {$tour}", 'summary' => '', 'columns' => [['attribute' => 'date_time_game', 'content' => function ($model) {
return '<strong>' . date('d.m.y H:i', $model['date_time_game']) . '</strong>';
}, 'contentOptions' => ['class' => 'reduceDateFont'], 'options' => ['class' => 'col-xs-1'], 'hAlign' => 'center', 'vAlign' => 'middle'], ['content' => function ($model) {
return "<row>" . "<div class = 'text-right col-xs-4'>" . $model['idTeamHome']['idTeam']['team_name'] . " " . "</div>" . "<div class = 'text-center col-xs-4'>" . "<strong>" . $model['score_home'] . " - " . $model['score_guest'] . "</strong>" . "</div>" . "<div class = 'text-left col-xs-4'>" . " " . $model['idTeamGuest']['idTeam']['team_name'] . "</div>" . "</row>" . "<div class='clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block'></div>" . "<row>" . "<div class = 'col-xs-4 col-xs-offset-4 col-sm-2 col-sm-offset-5 text-center'>" . Html::tag('div', isset($model['f_id']) ? $model['fscore_home'] . ' - ' . $model['fscore_guest'] : " - ", ['class' => !isset($model['f_id']) ? '' : ($model['fpoints'] == 0 ? 'bg-danger' : ($model['fpoints'] == 1 ? 'bg-info' : ($model['fpoints'] == 3 ? 'bg-success' : ($model['fpoints'] == 2 ? 'bg-warning' : ''))))]) . "</div>" . "<div class = 'col-xs-4 col-sm-2 col-sm-offset-3 text-right'>" . Html::tag('span', isset($model['f_id']) ? "Очки: " . $model['fpoints'] : '', []) . "</div>" . "</row>";
}, 'options' => ['class' => 'col-xs-11'], 'attribute' => 'fpoints', 'pageSummary' => function ($summary, $data, $widget) {
return "<div class = 'row'>" . "<div class = 'col-xs-10'>" . "<p class = 'pull-left'>Всего очков в туре:</p>" . "</div>" . "<div class = 'col-xs-2'>" . "<p class = 'pull-left'>{$summary}</p>" . "</div>" . "</div>";
}, 'hAlign' => 'right', 'vAlign' => 'middle']]]);
?>
<?php
} else {
?>
<?php
$form = ActiveForm::begin(['action' => ['site/forecast-save']]);
?>
<?php
echo GridView::widget(['dataProvider' => $tourGames[$tour], 'responsive' => false, 'hover' => true, 'showPageSummary' => true, 'responsiveWrap' => false, 'export' => false, 'bordered' => false, 'showHeader' => false, 'caption' => "Тур {$tour}", 'summary' => '', 'columns' => [['content' => function ($model) {
return '<strong>' . date('d.m.y H:i', $model['date_time_game']) . '</strong>';
}, 'options' => ['class' => 'col-xs-1'], 'contentOptions' => ['class' => 'reduceDateFont'], 'hAlign' => 'center', 'vAlign' => 'middle'], ['content' => function ($model) use($form) {
return isset($model['score_home']) ? "<row>" . "<div class = 'text-right col-xs-5'>" . $model['idTeamHome']['idTeam']['team_name'] . " " . "</div>" . "<div class = 'text-center col-xs-2'>" . "<strong>" . $model['score_home'] . " - " . $model['score_guest'] . "</strong>" . "</div>" . "<div class = 'text-left col-xs-5'>" . " " . $model['idTeamGuest']['idTeam']['team_name'] . "</div>" . "</row>" . "<div class='clearfix visible-xs-block'></div>" . "<row>" . "<div class = 'col-xs-2 col-xs-offset-5 text-center'>" . Html::tag('div', isset($model['f_id']) ? $model['fscore_home'] . ' - ' . $model['fscore_guest'] : " - ", ['class' => !isset($model['f_id']) ? '' : ($model['fpoints'] == 0 ? 'bg-danger' : ($model['fpoints'] == 1 ? 'bg-info' : ($model['fpoints'] == 3 ? 'bg-success' : ($model['fpoints'] == 2 ? 'bg-warning' : ''))))]) . "</div>" . "<div class = 'col-xs-2 col-xs-offset-3 text-right'>" . Html::tag('span', isset($model['f_id']) ? "Очки: " . $model['fpoints'] : '', []) . "</div>" . "</row>" : "<row>" . "<div class = 'text-right col-xs-5'>" . $model['idTeamHome']['idTeam']['team_name'] . " " . "</div>" . "<div class = 'text-center col-xs-2'>" . ' - ' . "</div>" . "<div class = 'text-left col-xs-5'>" . " " . $model['idTeamGuest']['idTeam']['team_name'] . "</div>" . "</row>" . "<row>" . "<div class = 'col-xs-12 text-center'>" . Html::input('number', "forecasts[{$model['id_game']}][fscore_home]", isset($model['f_id']) ? $model['fscore_home'] : '', ['class' => 'forecast', 'form' => $form->getID(), 'maxlength' => 2, 'disabled' => $model['date_time_game'] - time() < 60 * 60 ? true : false]) . Html::input('number', "forecasts[{$model['id_game']}][fscore_guest]", isset($model['f_id']) ? $model['fscore_guest'] : '', ['class' => 'forecast', 'maxlength' => 2, 'form' => $form->getID(), 'disabled' => $model['date_time_game'] - time() < 60 * 60 ? true : false]) . "</div>" . "</row>";
}, 'options' => ['class' => 'col-xs-11'], 'attribute' => 'fpoints', 'pageSummary' => function ($summary, $data, $widget) {
return "<div class = 'row'>" . "<div class = 'col-xs-11'>" . "<p class = 'pull-left'>Всего очков в туре:</p>" . "</div>" . "<div class = 'col-xs-1'>" . "<p class = 'pull-left'>{$summary}</p>" . "</div>" . "</div>";
}, 'vAlign' => 'middle']]]);
?>
<p class = 'pull-right'><?php
echo Html::submitButton('Сохранить', ['class' => 'btn btn-success', 'form' => $form->getId()]);
?>
</p>
<?php
示例11:
/* @var $model \app\models\ResetPasswordForm */
$this->title = 'Reset password';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-reset-password">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<p>Please choose your new password:</p>
<div class="row">
<div class="col-lg-5">
<?php
$form = ActiveForm::begin(['id' => 'reset-password-form', 'layout' => 'horizontal']);
?>
<?php
echo $form->field($model, 'password')->passwordInput();
?>
<div class="form-group">
<?php
echo Html::submitButton('Save', ['class' => 'btn btn-primary']);
?>
</div>
<?php
ActiveForm::end();
?>
</div>
</div>
</div>
示例12:
$this->registerJsFile('@web/public/ueditor/ueditor.all.min.js');
$this->registerJsFile('@web/public/ueditor/lang/zh-cn/zh-cn.js');
?>
<script type="text/javascript"></script>
<script type="text/javascript">
var ue = UE.getEditor('editor');
</script>
<style>
.inline .radio,.inline .checkbox{display: inline-block;margin: 0 5px;}
#editor{margin-top: 20px;padding:0;margin:20px 0;width:100%;height:auto;border: none;}
</style>
<?php
$form = ActiveForm::begin(['id' => 'upload', 'enableAjaxValidation' => false, 'options' => ['enctype' => 'multipart/form-data']]);
?>
<?php
echo $form->field($model, 'title')->textInput();
?>
<?php
echo $form->field($model, 'tags')->fileInput();
?>
<?php
echo $form->field($model, 'content')->textarea(['rows' => 6, 'id' => 'editor', 'class' => 'col-sm-1 col-md-12']);
?>
<?php
echo Html::submitButton('提交', ['class' => 'btn btn-primary', 'name' => 'submit-button']);
?>
<?php
示例13:
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\AdminRole */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $id string */
$id = 'admin-role-form';
?>
<div class="admin-role-form-block">
<?php
$form = ActiveForm::begin(['id' => $id, 'options' => ['class' => 'model-form'], 'layout' => 'horizontal', 'fieldConfig' => ['horizontalCssClasses' => ['label' => 'col-sm-3', 'offset' => 'col-sm-offset-3', 'wrapper' => 'col-sm-5']]]);
?>
<?php
echo $form->field($model, 'honor')->textInput(['maxlength' => 15]);
?>
<div class="form-group required">
<label class="control-label col-sm-3" for="adminrole-acls">权限</label>
<div class="col-sm-8" id="<?php
echo $model->formName() . '-acl';
?>
">
<?php
if ($model->id == 1) {
?>
<div style="margin-top: 5px;">拥有所有权限!</div>
<?php
} else {
示例14:
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\jui\DatePicker;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model app\modules\student\models\StuDocs */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="stu-docs-form">
<?php
$form = ActiveForm::begin(['id' => 'stu-docs-form', 'options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-7\"><span class='status'> </span>{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>
<?php
echo $form->field($model, 'stu_docs_details')->textInput(['maxlength' => 100]);
?>
<?php
echo $form->field($model, 'stu_docs_category_id')->dropDownList(ArrayHelper::map(\app\models\DocumentCategory::find()->all(), 'doc_category_id', 'doc_category_name'), ['prompt' => '---Select Category---']);
?>
<?php
echo $form->field($model, 'stu_docs_path')->fileInput(['maxlength' => 150]);
?>
<div class="hint col-sm-offset-1 col-lg-10" style="margin-bottom:2%; color:red"><b>Hint:- </b> Upload Only Jpeg, Jpg, Pdf, Txt, Doc, Png Type Document</div>
示例15:
<b>Телефон:</b> <?php
echo $settings->get('info.phone');
?>
<br />
<b>Адрес:</b> <?php
echo $settings->get('info.address');
?>
</p>
<p>
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
</p>
<div class="row">
<div class="col-lg-5">
<?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>']);