本文整理汇总了PHP中kartik\widgets\Select2类的典型用法代码示例。如果您正苦于以下问题:PHP Select2类的具体用法?PHP Select2怎么用?PHP Select2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Select2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
FlagIconAsset::register($this->getView());
$locales = [];
$languages = [];
if (!empty($this->countries)) {
array_walk($this->countries, function (&$data) {
$data = strtolower($data);
});
}
$countryRepository = new Country();
$data = $countryRepository->findAll();
foreach ($data as $code => $lang) {
if (empty($this->countries) || in_array(strtolower($code), $this->countries)) {
$locales[$code] = FlagIcon::flag($code);
$languages[$code] = $lang->name['english']['common'] . ' (' . reset($lang->name['native'])['common'] . ')';
}
}
$format = '
function format(state) {
var locales = ' . Json::encode($locales) . ';
if (!state.id) { return state.text; }
return locales[state.id] + " " + state.text;
}';
$escape = new JsExpression('function(m) { return m; }');
$this->getView()->registerJs($format, View::POS_HEAD);
$this->options = array_merge(['placeholder' => Yii::$app->translate->t('Choose country')], $this->options);
$pluginOptions = array_merge(['templateResult' => new JsExpression('format'), 'templateSelection' => new JsExpression('format'), 'escapeMarkup' => $escape], $this->pluginOptions);
$pluginEvents = array_merge([], $this->pluginEvents);
return Select2::widget(['model' => $this->model, 'attribute' => $this->attribute, 'name' => $this->name, 'value' => $this->value, 'options' => $this->options, 'data' => $languages, 'pluginOptions' => $pluginOptions, 'pluginEvents' => $pluginEvents]);
}
示例2: run
/**
* @inheritdoc
*/
public function run()
{
FlagIconAsset::register($this->getView());
$locales = [];
$ids = [];
$countryRepository = new Country();
$data = $countryRepository->findAll();
foreach ($this->currencies as $value) {
$key = $value->id;
if (!empty($value->country_flag)) {
$locales[$key] = FlagIcon::flag($value->country_flag);
} else {
// iterate data (countries list) to find country code with defined ($value->code) currency
foreach ($data as $code => $country_value) {
if (strcasecmp($country_value->currency['code'], $value->code) == 0) {
$locales[$key] = FlagIcon::flag($code);
break;
}
}
}
$ids[$key] = $value->code;
}
$currencyFormat = 'function currencyFormat(state) {
var locales = ' . Json::encode($locales) . ';
if (!state.id) { return state.text; }
return locales[state.id] + " " + state.text;
}';
$escape = new JsExpression('function(m) { return m; }');
$this->getView()->registerJs($currencyFormat, View::POS_HEAD);
$this->options = array_merge(['placeholder' => Yii::$app->translate->t('select currency')], $this->options);
$pluginOptions = array_merge(['templateResult' => new JsExpression('currencyFormat'), 'templateSelection' => new JsExpression('currencyFormat'), 'escapeMarkup' => $escape], $this->pluginOptions);
$pluginEvents = array_merge([], $this->pluginEvents);
return Select2::widget(['model' => $this->model, 'attribute' => $this->attribute, 'name' => $this->name, 'value' => $this->value, 'options' => $this->options, 'data' => $ids, 'pluginOptions' => $pluginOptions, 'pluginEvents' => $pluginEvents]);
}
示例3: init
/**
* Initializes the widget
*
* @throw InvalidConfigException
*/
public function init()
{
if (empty($this->pluginOptions['url'])) {
throw new InvalidConfigException("The 'pluginOptions[\"url\"]' property has not been set.");
}
if (empty($this->pluginOptions['depends']) || !is_array($this->pluginOptions['depends'])) {
throw new InvalidConfigException("The 'pluginOptions[\"depends\"]' property must be set and must be an array of dependent dropdown element ID.");
}
if (empty($this->options['class'])) {
$this->options['class'] = 'form-control';
}
parent::init();
if ($this->type !== self::TYPE_SELECT2 && !empty($this->options['placeholder'])) {
$this->data = ['' => $this->options['placeholder']] + $this->data;
}
if ($this->type === self::TYPE_SELECT2 && (!empty($this->options['placeholder']) || !empty($this->select2Options['options']['placeholder']))) {
$this->pluginOptions['placeholder'] = '';
} elseif ($this->type === self::TYPE_SELECT2 && !empty($this->pluginOptions['placeholder']) && $this->pluginOptions['placeholder'] !== false) {
$this->options['placeholder'] = $this->pluginOptions['placeholder'];
$this->pluginOptions['placeholder'] = '';
}
$this->_view = $this->getView();
$this->registerAssets();
if ($this->type === self::TYPE_SELECT2) {
if (empty($this->data)) {
$this->data = ['' => ''];
}
if ($this->hasModel()) {
$settings = ArrayHelper::merge($this->select2Options, ['model' => $this->model, 'attribute' => $this->attribute, 'data' => $this->data, 'options' => $this->options]);
} else {
$settings = ArrayHelper::merge($this->select2Options, ['name' => $this->name, 'value' => $this->value, 'data' => $this->data, 'options' => $this->options]);
}
echo Select2::widget($settings);
$id = 'jQuery("#' . $this->options['id'] . '")';
$text = ArrayHelper::getValue($this->pluginOptions, 'loadingText', 'Loading ...');
$this->_view->registerJs("{$id}.on('depdrop.beforeChange',function(e,i,v){{$id}.select2('data',{text: '{$text}'});});");
$this->_view->registerJs("{$id}.on('depdrop.change',function(e,i,v,c){{$id}.select2('val',{$id}.val());});");
} else {
echo $this->getInput('dropdownList', true);
}
}
示例4:
<?php
use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use kartik\datecontrol\DateControl;
use kartik\widgets\Select2;
/**
* @var yii\web\View $this
* @var common\models\empresa\Osconfemp $model
* @var yii\widgets\ActiveForm $form
*/
?>
<div class="osconfemp-form">
<?php
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_HORIZONTAL]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['coe_nombre' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\yii\\widgets\\MaskedInput', 'options' => ['mask' => 'A{3,10}9{0,5}']], 'coe_descri' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Descripción...', 'maxlength' => 60]], 'coe_tipo' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => Select2::classname(), 'options' => ['data' => Yii::$app->orcsis->getOpcTab($model->tableName(), 'coe_tipo'), 'options' => ['placeholder' => 'Enter Tipo de Dato...']]], 'coe_data' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => 'Enter Coe Data...', 'rows' => 6]]]]);
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
ActiveForm::end();
?>
</div>
示例5:
?>
<?php
echo $form->field($model, 'cargaHoraria')->textInput(['type' => 'number']);
?>
<?php
echo $form->field($model, 'palestrante_idPalestrante')->widget(Select2::classname(), ['data' => $arrayPalestrante, 'options' => ['placeholder' => 'Selecione um palestrante ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
<p><?php
echo Html::a('Novo Palestrante', ['palestrante/index'], ['class' => 'btn btn-primary']);
?>
<p>
<?php
echo $form->field($model, 'local_idlocal')->widget(Select2::classname(), ['data' => $arrayLocal, 'options' => ['placeholder' => 'Selecione um Local ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
<p><?php
echo Html::a('Novo Local', ['local/index'], ['class' => 'btn btn-primary']);
?>
<p>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? 'Criar Item de Programação' : 'Salvar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
<?php
ActiveForm::end();
?>
示例6: date
?>
<?php
//= $form->errorSummary($model);
?>
<?php
echo $form->field($roDetail, 'CREATED_AT', ['template' => "{input}"])->hiddenInput(['value' => date('Y-m-d H:i:s'), 'readonly' => true]);
?>
<?php
echo $form->field($roDetail, 'KD_CORP')->dropDownList($userCorp, ['id' => 'rodetail-kd_corp', 'prompt' => ' -- Pilih Salah Satu --'])->label('Perusahaan');
echo $form->field($roDetail, 'KD_TYPE')->widget(DepDrop::classname(), ['type' => DepDrop::TYPE_SELECT2, 'data' => $brgType, 'options' => ['id' => 'rodetail-kd_type'], 'pluginOptions' => ['depends' => ['rodetail-kd_corp'], 'url' => Url::to(['/purchasing/sales-order/corp-type']), 'initialize' => true]])->label('Type');
echo $form->field($roDetail, 'KD_KATEGORI')->widget(DepDrop::classname(), ['type' => DepDrop::TYPE_SELECT2, 'data' => $brgKtg, 'options' => ['id' => 'rodetail-kd_kategori'], 'pluginOptions' => ['depends' => ['rodetail-kd_corp', 'rodetail-kd_type'], 'url' => Url::to(['/purchasing/sales-order/type-kat']), 'initialize' => true]]);
echo $form->field($roDetail, 'KD_BARANG')->widget(DepDrop::classname(), ['type' => DepDrop::TYPE_SELECT2, 'data' => $brgProdak, 'options' => ['id' => 'rodetail-kd_barang'], 'pluginOptions' => ['depends' => ['rodetail-kd_kategori'], 'url' => Url::to(['/purchasing/sales-order/brgkat']), 'initialize' => true]]);
echo $form->field($roDetail, 'NM_BARANG')->hiddenInput(['value' => ''])->label(false);
echo $form->field($roDetail, 'UNIT')->widget(Select2::classname(), ['data' => $brgUnit, 'options' => ['placeholder' => 'Pilih Unit Barang ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
<?php
echo $form->field($roDetail, 'RQTY')->textInput(['maxlength' => true, 'placeholder' => 'Jumlah Barang']);
?>
<?php
echo $form->field($roDetail, 'NOTE')->textarea(array('rows' => 2, 'cols' => 5))->label('Informasi');
?>
<div class="form-group">
<?php
echo Html::submitButton($roDetail->isNewRecord ? 'Create' : 'Update', ['class' => $roDetail->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
示例7:
<?php
echo $form->field($model, 'date_input')->textInput();
?>
<?php
echo $form->field($model, 'last_update')->textInput();
?>
<?php
echo $form->field($model, 'last_staff')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'risk_status')->widget(Select2::classname(), ['data' => ArrayHelper::map(Status::find()->all(), 'STATUS_ID', 'STATUS_NAME'), 'options' => ['placeholder' => 'เลือกสถานะของรายการ ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
</div>
<div class="form-group field-upload_files">
<label class="control-label" for="upload_files[]"> ภาพถ่าย </label>
<div>
<?php
echo FileInput::widget(['name' => 'upload_ajax[]', 'options' => ['multiple' => true, 'accept' => 'image/*'], 'pluginOptions' => ['overwriteInitial' => false, 'initialPreviewShowDelete' => true, 'initialPreview' => $initialPreview, 'initialPreviewConfig' => $initialPreviewConfig, 'uploadUrl' => Url::to(['/priskhead/upload-ajax']), 'uploadExtraData' => ['ref' => $model->ref], 'maxFileCount' => 100]]);
?>
</div>
</div>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => ($model->isNewRecord ? 'btn btn-success' : 'btn btn-primary') . ' btn-lg btn-block']);
示例8: date
?>
<?php
echo $form->field($model, 'identification_type', ['options' => ['class' => 'col-xs-6']])->radioList(DictApplicant::$identificationType);
?>
<?php
echo $form->field($model, 'marital_status', ['options' => ['class' => 'col-xs-6']])->radioList(DictApplicant::$maritalStatus);
?>
<?php
echo $form->field($model, 'identification_number', ['options' => ['class' => 'col-xs-6']])->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'social_security_number', ['options' => ['class' => 'col-xs-6']])->widget(MaskedInput::className(), ['mask' => '999-99-9999']);
?>
<?php
echo $form->field($model, 'identification_state', ['options' => ['class' => 'col-xs-6 padding-right0']])->widget(Select2::classname(), ['data' => ArrayHelper::map(State::find()->all(), 'abbreviation', 'abbreviation'), 'options' => ['placeholder' => 'Select a state ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
<?php
echo $form->field($model, 'identification_expiration_date', ['options' => ['class' => 'col-xs-6']])->label('ID Expiration Date')->widget(DatePicker::classname(), ['type' => DatePicker::TYPE_COMPONENT_PREPEND, 'removeButton' => false, 'options' => ['value' => $model->identification_expiration_date ? date('m/d/Y', $model->identification_expiration_date) : ''], 'pluginOptions' => ['autoclose' => true, 'format' => 'mm/dd/yyyy']]);
?>
<?php
echo $form->field($model, 'occupation', ['options' => ['class' => 'col-xs-6']])->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'employer', ['options' => ['class' => 'col-xs-6']])->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'total_annual_income', ['options' => ['class' => 'col-xs-6']])->radioList(DictApplicant::$totalAnnualIncome);
?>
<?php
echo $form->field($model, 'years_with_advisor', ['options' => ['class' => 'col-xs-6']])->radioList(DictApplicant::$yearsWithAdvisor);
示例9:
'pluginOptions' => [
'allowClear' => true,
'multiple'=>true
],
]);?> -->
<?php
$options = ['multiple' => true];
// echo $form->field($model, $attribute)->listBox($items, $options);
echo $form->field($model, 'DEP_SUB_ID')->widget(DualListbox::className(), ['items' => $dep, 'options' => $options, 'clientOptions' => ['moveOnSelect' => false, 'selectedListLabel' => 'Selected Items', 'nonSelectedListLabel' => 'Available Items']]);
?>
<?php
echo $form->field($model, 'DESTINATION_TO')->widget(Select2::classname(), ['data' => $dropemploy, 'options' => ['placeholder' => 'Pilih Karyawan ...'], 'pluginOptions' => ['allowClear' => true]]);
$options = ['multiple' => true];
// echo $form->field($model, $attribute)->listBox($items, $options);
echo $form->field($model, 'USER_CC')->widget(DualListbox::className(), ['items' => $dropemploy, 'options' => $options, 'clientOptions' => ['moveOnSelect' => false, 'selectedListLabel' => 'Selected Items', 'nonSelectedListLabel' => 'Available Items']]);
?>
<?php
echo $form->field($model, 'PLAN_DATE1')->widget(DatePicker::classname(), ['options' => ['placeholder' => 'Enter...', 'value' => $tgl], 'pluginOptions' => ['autoclose' => true], 'pluginEvents' => ['show' => "function(e) {show}"]]);
?>
<?php
echo $form->field($model, 'PLAN_DATE2')->widget(DatePicker::classname(), ['options' => ['placeholder' => 'Enter...', 'value' => $tgl_1], 'pluginOptions' => ['autoclose' => true], 'pluginEvents' => ['show' => "function(e) {show}"]]);
?>
示例10: getItem
/**
* @param null $options
* @param null $pluginOptions
*
* @return string
* @throws \Exception
*/
public function getItem($options = null, $pluginOptions = null)
{
switch ($this->type) {
case self::TYPE_TEXT:
return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_EMAIL:
return Html::input('email', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_NUMBER:
return Html::input('number', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_TEXTAREA:
return Html::textarea('Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_COLOR:
return ColorInput::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'options' => $options != null ? $options : ['class' => 'form-control']]);
case self::TYPE_DATE:
return DatePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['format' => 'yyyy-mm-dd', 'todayHighlight' => true]]);
case self::TYPE_TIME:
return TimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['minuteStep' => 1, 'showSeconds' => true, 'showMeridian' => false]]);
case self::TYPE_DATETIME:
return DateTimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['format' => 'yyyy-mm-dd H:i:s', 'todayHighlight' => true]]);
case self::TYPE_PASSWORD:
return PasswordInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['showMeter' => true, 'toggleMask' => false]]);
case self::TYPE_ROXYMCE:
return RoxyMceWidget::widget(['id' => 'Setting_' . $this->code, 'name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'action' => Url::to(['roxymce/default']), 'options' => $options != null ? $options : ['title' => $this->getName()], 'clientOptions' => $pluginOptions != null ? $pluginOptions : []]);
case self::TYPE_SELECT:
return Select2::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'data' => $this->getStoreRange(), 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['allowClear' => true]]);
case self::TYPE_MULTI_SELECT:
$options['multiple'] = true;
if (!isset($options['class'])) {
$options['class'] = 'form-control';
}
return Select2::widget(['name' => 'Setting[' . $this->code . ']', 'value' => explode(",", $this->value), 'data' => $this->getStoreRange(), 'options' => $options, 'pluginOptions' => ['allowClear' => true]]);
case self::TYPE_FILE_PATH:
$value = Yii::getAlias($this->store_dir) . DIRECTORY_SEPARATOR . $this->value;
return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control', 'multiple' => false], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreview' => !$this->isNewRecord ? [$this->value] : []]]);
case self::TYPE_FILE_URL:
$value = $this->store_url . '/' . $this->value;
return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreviewAsData' => true, 'initialPreviewFileType' => self::fileType(pathinfo($this->value, PATHINFO_EXTENSION)), 'initialPreview' => !$this->isNewRecord ? $value : [], 'initialCaption' => $this->value]]);
case self::TYPE_PERCENT:
return RangeInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'html5Options' => ['min' => 0, 'max' => 100, 'step' => 1], 'options' => $options != null ? $options : ['class' => 'form-control'], 'addon' => ['append' => ['content' => '%']]]);
case self::TYPE_SWITCH:
$selector = explode(',', $this->store_range);
if (count($selector) != 2) {
throw new ErrorException(Yii::t('setting', 'Switch Field should have store with 2 value, and negative is first. Example: no,yes'), 500);
}
return Html::hiddenInput('Setting[' . $this->code . ']', $selector[0]) . SwitchInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $selector[1], 'containerOptions' => ['class' => 'nv-switch-container'], 'options' => $options != null ? $options : [], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['state' => $this->value == $selector[1], 'size' => 'small', 'offText' => ucfirst($selector[0]), 'onText' => ucfirst($selector[1])]]);
case self::TYPE_CHECKBOX:
$random = rand(1000, 9999);
return Html::checkboxList('Setting[' . $this->code . ']', explode(",", $this->value), $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list checkbox', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
$html = Html::beginTag('div');
$html .= Html::checkbox($name, $checked, ['id' => 'Setting_checkbox_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
$html .= Html::label($label, 'Setting_checkbox_' . $label . '_' . $index . '_' . $random);
$html .= Html::endTag('div');
return $html;
}]);
case self::TYPE_RADIO:
$random = rand(1000, 9999);
return Html::radioList('Setting[' . $this->code . ']', $this->value, $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list radio', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
$html = Html::beginTag('div');
$html .= Html::radio($name, $checked, ['id' => 'Setting_radio_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
$html .= Html::label($label, 'Setting_radio_' . $label . '_' . $index . '_' . $random);
$html .= Html::endTag('div');
return $html;
}]);
case self::TYPE_SEPARATOR:
return '<hr>';
default:
return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
}
}
示例11: certificateNoParse
?>
<div class="row">
<div class="col-sm-12">
<?php
echo Html::submitButton('保 存', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-info']);
?>
</div>
</div>
<?php
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 6, 'attributes' => ['personal_id' => ['type' => Form::INPUT_HIDDEN, 'label' => false, 'columnOptions' => ['colspan' => 0]], 's_date' => ['type' => Form::INPUT_TEXT, 'columnOptions' => ['colspan' => 2], 'options' => ['placeholder' => '请输入登记日期..', 'maxlength' => 8]], 'code1' => ['type' => Form::INPUT_TEXT, 'columnOptions' => ['colspan' => 2], 'options' => ['placeholder' => '请输入员工编码..', 'maxlength' => 36]], 'name1' => ['type' => Form::INPUT_TEXT, 'columnOptions' => ['colspan' => 2], 'options' => ['placeholder' => '请输入员工姓名..', 'maxlength' => 50]]]]);
?>
</div>
<div class="col-sm-12">
<?php
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 4, 'attributes' => ['fcode' => ['type' => Form::INPUT_TEXT, 'options' => ['id' => 'p-fcode', 'placeholder' => '身份证号', 'maxlength' => 18]], 'sex' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('psex'), 'options' => ['id' => 'p-sex', 'readOnly' => true]], 'birthdate' => ['type' => Form::INPUT_TEXT, 'options' => ['id' => 'p-birthdate', 'placeholder' => '请输入出生日期..', 'maxlength' => 8, 'readOnly' => true]], 'unit' => ['type' => Form::INPUT_TEXT, 'options' => ['id' => 'p-unit', 'readOnly' => true, 'maxlength' => 30]], 'flag' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('pflag'), 'options' => ['placeholder' => 'Enter Flag...', 'maxlength' => 2]], 'hkxz' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('chkxz'), 'options' => ['placeholder' => 'Enter Hkxz...', 'maxlength' => 2]], 'marry' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('pmarry'), 'options' => ['id' => 'p-marry', 'placeholder' => 'Enter Marry...', 'maxlength' => 2]], 'marrydate' => ['type' => Form::INPUT_TEXT, 'options' => ['id' => 'p-marrydate', 'placeholder' => 'Enter Marrydate...', 'maxlength' => 8]], 'memo1' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('pmemo1'), 'options' => ['placeholder' => 'Enter Memo1...', 'maxlength' => 2]], 'selfno' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Selfno...']], 'lhdate' => ['type' => Form::INPUT_TEXT, 'options' => ['id' => 'p-lhdate', 'placeholder' => 'Enter Lhdate...', 'maxlength' => 8]], 'zhdate' => ['type' => Form::INPUT_TEXT, 'options' => ['id' => 'p-zhdate', 'maxlength' => 8]], 'work1' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('pwork1'), 'options' => ['placeholder' => 'Enter Work1...', 'maxlength' => 2]], 'childnum' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Childnum...']], 'obect1' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => Select2::className(), 'options' => ['data' => Preferences::getByClassmark('pobect1'), 'options' => ['placeholder' => '--请选择--'], 'pluginOptions' => ['allowClear' => true]]], 'fhdate' => ['type' => Form::INPUT_TEXT, 'options' => ['id' => 'p-fhdate', 'maxlength' => 8]], 'mz' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('pmz'), 'options' => ['placeholder' => 'Enter Mz...', 'maxlength' => 2]], 'whcd' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => Select2::className(), 'options' => ['data' => Preferences::getByClassmarkReturnName1ToName1('pwhcd'), 'options' => ['placeholder' => '请输入..', 'id' => 'p-whcd', 'data-classmark' => 'pwhcd', 'data-classmarkcn' => '文化程度'], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10]]], 'title' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => Select2::className(), 'options' => ['data' => Preferences::getByClassmarkReturnName1ToName1('ptitle'), 'options' => ['placeholder' => '请输入..', 'id' => 'p-title', 'data-classmark' => 'ptitle', 'data-classmarkcn' => '职称'], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10]]], 'zw' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => Select2::className(), 'options' => ['data' => Preferences::getByClassmarkReturnName1ToName1('awork1'), 'options' => ['placeholder' => '请输入..', 'id' => 'p-zw', 'data-classmark' => 'awork1', 'data-classmarkcn' => '职务'], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10]]], 'is_dy' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => Select2::className(), 'options' => ['data' => Preferences::getByClassmarkReturnName1ToName1('pis_dy'), 'options' => ['placeholder' => '请输入..', 'id' => 'p-is_dy', 'data-classmark' => 'pis_dy', 'data-classmarkcn' => '政治面貌'], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10]]], 'onlysign' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('ponlysign'), 'options' => ['placeholder' => 'Enter Onlysign...', 'maxlength' => 2]], 'tel' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Tel...', 'maxlength' => 50]], 'jobdate' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Jobdate...', 'maxlength' => 8]], 'address1' => ['type' => Form::INPUT_TEXT, 'columnOptions' => ['colspan' => 2], 'options' => ['placeholder' => 'Enter Address1...', 'maxlength' => 80]], 'grous' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => Select2::className(), 'options' => ['data' => Preferences::getByClassmarkReturnName1ToName1('pgrous'), 'options' => ['placeholder' => '请输入..', 'id' => 'p-grous', 'data-classmark' => 'pgrous', 'data-classmarkcn' => '所属街道'], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' '], 'maximumInputLength' => 10]]], 'ingoingdate' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter Ingoingdate...', 'maxlength' => 8]]]]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 4, 'attributes' => ['hkaddr' => ['type' => Form::INPUT_TEXT, 'columnOptions' => ['colspan' => 2], 'options' => ['placeholder' => 'Enter Hkaddr...', 'maxlength' => 80]], 'logout' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('plogout'), 'options' => ['placeholder' => 'Enter Logout...']], 'e_date' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter E Date...', 'maxlength' => 8]]]]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 4, 'attributes' => ['memo' => ['type' => Form::INPUT_TEXT, 'columnOptions' => ['colspan' => 2], 'options' => ['placeholder' => 'Enter Memo...', 'maxlength' => 254]], 'checktime' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Preferences::getByClassmark('pchecktime'), 'options' => ['id' => 'p-checktime', 'placeholder' => 'Enter Checktime...', 'maxlength' => 2]]]]);
ActiveForm::end();
?>
</div>
</div>
</div>
<?php
\common\widgets\JsBlock::begin();
?>
<script type="text/javascript">
//身份证合法性
function certificateNoParse(certificateNo){
示例12:
<div class="tmaster-form">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'nolphsp')->textInput(['maxlength' => 6]);
?>
<?php
echo $form->field($model, 'tgllhpsp')->widget(DatePicker::className(), ['inline' => false, 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]);
?>
<?php
echo $form->field($model, 'idkapal')->widget(Select2::classname(), ['data' => ArrayHelper::map(Kapal::find()->all(), 'kapal_id', 'kapal_nama'), 'language' => 'en', 'options' => ['placeholder' => 'Pilih Kapal ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
<?php
echo $form->field($model, 'voy')->textInput(['maxlength' => 20]);
?>
<?php
echo $form->field($model, 'idagen')->dropDownList(ArrayHelper::map(Tagen::find()->all(), 'id', 'namaagen'), ['prompt' => 'pilih negara pelabuhan asal']);
?>
<?php
echo $form->field($model, 'idpelasal')->dropDownList(ArrayHelper::map(Tnegpelabuhan::find()->all(), 'idpel', 'negarapelabuhan'), ['prompt' => 'pilih negara pelabuhan asal']);
示例13: JsExpression
use kartik\widgets\Select2;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\JsExpression;
use yii\widgets\ActiveForm;
?>
<div class="city-form">
<?php
$form = ActiveForm::begin(['id' => 'city-form']);
?>
<hr>
<?php
echo $form->field($model, 'name')->widget(Select2::className(), ['size' => Select2::MEDIUM, 'language' => 'ru', 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => Url::to(['/city/city/city-list']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('function(city) { return city.text; }'), 'templateSelection' => new JsExpression('function (city) { return city.text; }')]]);
?>
<hr>
<div class="form-group">
<?php
echo Html::submitButton('Создать', ['class' => 'btn btn-success']);
?>
<?php
echo Html::button('Закрыть', ['class' => 'btn btn-default', 'data-dismiss' => 'modal']);
?>
</div>
<?php
ActiveForm::end();
?>
示例14: function
<div class="col-md-6">
<?php
echo $form->field($model, 'title');
?>
</div>
<!--?= $form->field($model, 'file') ?-->
<div class="col-md-6">
<!--?= $form->field($model, 'share_to') ?-->
<?php
$usr = User::find()->all();
$usrs = ArrayHelper::map($usr, function ($model) {
return $model->_id->{'$id'};
}, 'username');
echo $form->field($model, 'share_to')->label('Share To')->widget(Select2::classname(), ['data' => $usrs, 'options' => ['placeholder' => 'Select User', 'id' => 'file_id'], 'pluginOptions' => ['allowClear' => true]]);
?>
</div>
</div>
<div class="row">
<div class="col-md-8">
<!--?= $form->field($model, 'file')->fileInput() ?-->
<?php
echo $form->field($model, 'file')->widget(FileInput::classname(), ['options' => ['accept' => 'file/*'], 'pluginOptions' => ['previewFileType' => 'image', 'showUpload' => false]]);
?>
</div>
<?php
$model->status = 1;
?>
<?php
示例15:
?>
<?php
echo $form->field($model, 'title')->label(false)->textInput(['placeholder' => 'freetext search']);
?>
<?php
if (isset($afterSearchTextCallback)) {
call_user_func($afterSearchTextCallback, $this, $form, $model);
}
echo $form->field($model, 'date_published', ['addon' => ['prepend' => ['content' => '<i class="glyphicon glyphicon-calendar"></i>']], 'options' => ['class' => 'drp-container form-group']])->widget(DateRangePicker::classname(), ['useWithAddon' => true, 'convertFormat' => true, 'presetDropdown' => true, 'pluginOptions' => ['locale' => ['format' => 'd M Y', 'separator' => ' to '], 'opens' => 'left']]);
if (isset($afterSearchCalendarCallback)) {
call_user_func($afterSearchCalendarCallback, $this, $form, $model);
}
// Normal select with ActiveForm & model
echo $form->field($model, 'keywords')->widget(Select2::classname(), ['id' => 'search-label', 'data' => \humanized\scoopit\models\gui\SearchLabel::getSelectData(), 'options' => ['placeholder' => 'Select keywords ...'], 'pluginOptions' => ['multiple' => true, 'allowClear' => true]])->label(false);
if (isset($afterSearchKeywordCallback)) {
call_user_func($afterSearchKeywordCallback, $this, $form, $model);
}
?>
<div class="form-group">
<?php
echo Html::submitButton('Search', ['class' => 'btn btn-primary']);
?>
<?php
echo Html::resetButton('Reset', ['class' => 'btn btn-default']);
?>
</div>
<?php