本文整理汇总了PHP中yii\jui\AutoComplete::widget方法的典型用法代码示例。如果您正苦于以下问题:PHP AutoComplete::widget方法的具体用法?PHP AutoComplete::widget怎么用?PHP AutoComplete::widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\jui\AutoComplete
的用法示例。
在下文中一共展示了AutoComplete::widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
use yii\helpers\Html;
use yii\helpers\Url;
use yii\jui\AutoComplete;
$this->title = '';
if ($locale) {
$this->title = \Locale::getDisplayName($locale, Yii::$app->language) . ', ' . Html::encode($locale) . ' - ';
}
$this->title .= 'PHP intl extension, ICU data tables';
?>
<?php
echo Html::beginForm(['site/index'], 'get', ['class' => 'form-horizontal']);
?>
<div class="input-group">
<?php
echo AutoComplete::widget(['name' => 'locale', 'value' => $locale, 'options' => ['class' => 'form-control', 'placeholder' => 'Enter locale code such as "en" or "en_US"', 'autofocus' => true], 'clientOptions' => ['source' => Url::toRoute(['site/suggest-locale'])]]);
?>
<span class="input-group-btn">
<?php
echo Html::submitButton('Find', ['class' => 'btn btn-primary']);
?>
</span>
</div>
<?php
echo Html::endForm();
?>
<?php
if ($locale) {
?>
示例2: autocompleteJui
public function autocompleteJui($opts)
{
$id = $this->getInputId();
$options = array_merge_recursive(['id' => $id . '_autoComplete', 'clientOptions' => ['select' => new JsExpression("function( event, ui ) { \$( '#{$id}' ).val( ui.item.id ); }"), 'change' => new JsExpression("function(){ if( \$( '#{$id}' ).val() <= 0 ){ \$(this).val(null); }}"), 'search' => new JsExpression("function(){ \$( '#{$id}' ).val(null); }")]], $opts);
$hidden = Html::activeHiddenInput($this->model, $this->attribute);
$autocomplete = AutoComplete::widget($options);
Yii::$app->getView()->registerJs("\$('body').on('autocompletecreate', 'input', function(e, ui){" . "\$(this).addClass('form-control') });", View::POS_END, 'autocompletecreate');
$this->parts['{input}'] = $hidden . $autocomplete;
return $this;
}
示例3: JsExpression
/* @var $this yii\web\View */
/* @var $model app\models\Access */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="access-form">
<?php
$form = ActiveForm::begin();
?>
<label for="autocomplete_user_id">
Выберите пользователя
</label>
<?php
echo \yii\jui\AutoComplete::widget(['id' => 'autocomplete_user_id', 'name' => 'user_id', 'clientOptions' => ['source' => \app\models\User::find()->select(['CONCAT(`name`, \' \', `surname`) as value', 'CONCAT(`name`, \' \', `surname`) as label', 'id'])->where("id != " . Yii::$app->user->id)->asArray()->all(), 'select' => new JsExpression("function( event, ui ) {\n \$('#access-user_id').val(ui.item.id);\n }")], 'options' => ['class' => 'form-control']]);
?>
<?php
echo Html::activeHiddenInput($model, 'user_id');
?>
<br>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
<?php
ActiveForm::end();
?>
示例4:
<?php
echo \common\widgets\Alert::widget();
?>
<div class="box">
<div class="content">
<div class="brand-create">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<!-- --><?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php
echo Html::a('Create Brand', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'emptyText' => 'You don\'t have any brands', 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'filter' => AutoComplete::widget(['model' => $searchModel, 'attribute' => 'title', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Brand::getAutoCompleteItems('title')]])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}{delete}']]]);
?>
</div>
</div>
</div>
</div>
示例5: function
<section class="content">
<?php
echo \common\widgets\Alert::widget();
?>
<div class="box box-primary">
<div class="box-body">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<p>
<?php
if (\Yii::$app->user->can('create-product')) {
?>
<?php
echo Html::a(Yii::t('app', 'Create Product'), ['create'], ['class' => 'btn btn-success']);
?>
<?php
}
?>
</p>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'emptyText' => 'You don\'t have any products', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'filter' => AutoComplete::widget(['model' => $searchModel, 'attribute' => 'title', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Product::getAutoCompleteItems('title')]])], ['attribute' => 'ui', 'filter' => AutoComplete::widget(['model' => $searchModel, 'attribute' => 'ui', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Product::getAutoCompleteItems('ui')]])], ['class' => '\\pheme\\grid\\ToggleColumn', 'attribute' => 'active', 'enableAjax' => false, 'filter' => [1 => Yii::t('yii', 'Yes'), 0 => Yii::t('yii', 'No')]], ['class' => 'yii\\grid\\ActionColumn', 'template' => Product::getGridButtonsTemplate(), 'buttons' => ['delete' => function ($url, $model, $key) {
$options = ['title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'data-confirm' => 'Are you sure you want to delete this item?', 'data-method' => 'post', 'data-pjax' => '0'];
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
}]]]]);
?>
</div>
</div>
</section>
示例6: JsExpression
<?php
echo Html::label('Print Count:');
?>
<br>
<?php
echo Html::input('text', 'jml', '10', ['id' => 'jml', 'style' => 'width:80px;']);
?>
</td>
</tr>
</tbody>
</table>
</div>
<div class="form-group" style="padding: 15px; padding-top: 0px;">
<label for="product">Product :</label>
<?php
echo AutoComplete::widget(['name' => 'product', 'id' => 'product', 'clientOptions' => ['source' => new JsExpression('yii.global.sourceProduct'), 'select' => new JsExpression('yii.master.onProductSelect'), 'delay' => 100], 'options' => ['class' => 'form-control', 'style' => 'width:60%;']]);
?>
<?php
echo Html::hiddenInput('barcodeValue', '', ['id' => 'barcodeValue']);
?>
</div>
</div>
<div class="box-footer">
<?php
echo Html::button(' Generate', ['onclick' => 'generateBarcode();', 'class' => 'btn btn-warning fa fa-qrcode']);
?>
<?php
echo Html::button(' Print', ['onclick' => 'print();', 'class' => 'btn btn-info fa fa-print']);
?>
</div>
</div>
示例7: ArrayDataProvider
//js
UserAsset::register($this);
//users
$dataProvider = new ArrayDataProvider(['allModels' => User::findAll($model->users), 'pagination' => false]);
//attribute name
$name = Html::getInputName($model, 'users') . '[]';
?>
<fieldset>
<div class="form-group">
<div class="col-sm-8 col-md-6">
<div class="input-group">
<?php
echo AutoComplete::widget(['name' => 'email', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Url::toRoute('users'), 'create' => new JsExpression('function(event, ui) {
$("#role-form input.ui-autocomplete-input").autocomplete("instance")._renderItem = function(ul, item) {
return $("<li>").html(item.html).appendTo(ul);
};
}')]]);
?>
<span class="input-group-btn">
<?php
echo Html::a(Yii::t('user', 'Add'), ['assign'], ['class' => 'btn btn-default assign', 'disabled' => true]);
?>
</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-8 col-md-6">
<?php
示例8: JsExpression
echo $form->field($model, 'orderNum');
?>
</div>
<div class="col-lg-6">
<?php
echo $form->field($model, 'city');
?>
</div>
<div class="col-lg-12">
<?php
echo $form->field($model, 'clientId')->hiddenInput();
?>
<?php
echo AutoComplete::widget(['name' => 'State', 'id' => 'ddd', 'clientOptions' => ['source' => Url::to(['clients/search']), 'select' => new JsExpression("function( event, ui ) {\n \$('#orders-clientid').val(ui.item.id);\n }")], 'options' => ['class' => 'form-control clients-main-search']]);
?>
</div>
<div class="col-lg-12">
<?php
echo $form->field($model, 'deliveryId')->dropDownList($delivery);
?>
</div>
<div class="col-lg-12">
<?php
echo $form->field($model, 'payment')->dropDownList($model->paymentArr);
?>
</div>
示例9: JsExpression
<?php
$form = ActiveForm::begin();
?>
<?php
GalleryWidget::printHiddenFields($covers);
?>
<div class="col-md-8" style="margin-bottom: 20px;">
<div class="form-group field-release-artist_id required">
<?php
echo Html::label('Artist Name', null, ['class' => 'control-label']);
?>
<span id="add_name" style="color: grey; margin-left: 5px;"></span>
<?php
echo AutoComplete::widget(['name' => 'artist_name', 'id' => 'artist_name', 'clientOptions' => ['source' => new JsExpression("function(request, response) {\n \$.getJSON('" . Url::toRoute('artist/ajax-search', true) . "', {\n term: request.term\n }, response);\n }"), 'autoFill' => true, 'minLength' => '1', 'select' => new JsExpression("function(event, ui) {\n \$('#release-artist_id').val(ui.item.id);\n if (ui.item.add_name) \$('#add_name').text('(' + ui.item.add_name + ')');\n }"), 'search' => new JsExpression("function(event, ui) {\n \$('#add_name').text('');\n \$('#release-artist_id').val('');\n }"), 'response' => new JsExpression("function(event, ui) {\n if (ui.content.length > 0) {\n var value = \$('#artist_name').val().toLowerCase();\n var item = ui.content[0];\n var names = [item.original_name.toLowerCase()];\n if (item.latin_name) names.push(item.latin_name.toLowerCase());\n if (\$.inArray(value, names) > -1) \$('#release-artist_id').val(item.id);\n \$('.field-release-artist_id .info-block').text('');\n } else {\n \$('.field-release-artist_id .info-block').text('New Artist will be created.');\n }\n }")], 'options' => ['class' => 'form-control'], 'value' => $artist_name]);
$this->registerJs("\$('#{$form->options['id']}').yiiActiveForm('add', {\n 'id': 'artist_name',\n 'name': 'artist_name',\n 'container': '.field-release-artist_id',\n 'input': '#artist_name',\n 'validate': function(attribute, value, messages, deferred, \$form) {\n yii.validation.required(value, messages, {\n 'message': 'Artist Name cannot be blank.'\n });\n yii.validation.string(value, messages, {\n 'message': 'Artist Name must be a string.',\n 'max': 255,\n 'tooLong': 'Artist Name should contain at most 255 characters.',\n 'skipOnEmpty': 1\n });\n value = yii.validation.trim(\$form, attribute, []);\n }\n })", View::POS_LOAD);
?>
<div class="help-block"></div>
<div class="info-block"></div>
<?php
echo Html::activeHiddenInput($release, 'artist_id', ['value' => $release->artist_id]);
?>
</div>
<?php
echo $form->field($release, 'original_name')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($release, 'latin_name')->textInput(['maxlength' => true]);
示例10: JsExpression
?>
</div>
</div>
<div class="box-body">
<?php
echo $form->field($model, 'purchase_num');
?>
<?php
echo '';
?>
<?php
$el_id = Html::getInputId($model, 'id_supplier');
$field = $form->field($model, "id_supplier", ['template' => "{label}\n{input}{text}\n{error}"]);
$field->labelOptions['for'] = $el_id;
$field->hiddenInput(['id' => 'id_supplier']);
$field->parts['{text}'] = AutoComplete::widget(['model' => $model, 'attribute' => 'idSupplier[nm_supplier]', 'options' => ['class' => 'form-control', 'id' => $el_id], 'clientOptions' => ['source' => new JsExpression("yii.purchase.sourceSupplier")]]);
echo $field;
?>
<?php
echo $form->field($model, 'purchaseDate')->widget('yii\\jui\\DatePicker', ['options' => ['class' => 'form-control', 'style' => 'width:50%'], 'clientOptions' => ['dateFormat' => 'dd-mm-yy']]);
?>
<?php
echo $form->field($model, 'status')->dropDownList([Purchase::STATUS_DRAFT => 'Draft', Purchase::STATUS_RECEIVE => 'Receive'], ['prompt' => '--status--']);
?>
</div>
<div class="box-footer">
<?php
echo Html::submitButton('Search', ['class' => 'btn btn-primary', 'click' => 'js:$(\'#kecilin\').click();']);
?>
<?php
示例11: JsExpression
?>
<div class=" product-uom-form col-lg-6" style="padding-left: 0px;">
<?php
$form = ActiveForm::begin();
?>
<div class="panel panel-primary">
<div class="panel-heading">Product Uoms</div>
<div class="panel-body">
<?php
$id_input = Html::getInputId($model, 'id_product');
$field = $form->field($model, 'id_product', ['template' => "{label}\n{input}\n{text}\n{hint}\n{error}"]);
$field->labelOptions['for'] = $id_input;
$field->input('hidden', ['id' => 'id_product']);
$field->parts['{text}'] = AutoComplete::widget(['model' => $model, 'attribute' => 'idProduct[nm_product]', 'options' => ['class' => 'form-control', 'id' => $id_input], 'clientOptions' => ['source' => Url::toRoute(['product/auto-product']), 'select' => new JsExpression('function(event,ui){$(\'#id_product\').val(ui.item.did)}'), 'open' => new JsExpression('function(event,ui){$(\'#id_product\').val(\'\')}')]]);
echo $field;
?>
<?php
echo $form->field($model, 'id_uom')->dropDownList(ArrayHelper::map(Uom::find()->all(), 'id_uom', 'nm_uom'), ['style' => 'width:200px;']);
?>
<?php
echo $form->field($model, 'isi')->textInput();
?>
</div>
</div>
示例12: JsExpression
use yii\helpers\Html;
use biz\purchase\models\PurchaseDtl;
use mdm\widgets\TabularInput;
use biz\purchase\assets\PurchaseAsset;
use biz\app\assets\BizDataAsset;
use biz\master\components\Helper as MasterHelper;
/* @var $details PurchaseDtl[] */
/* @var $model biz\purchase\models\Purchase */
/* @var $this yii\web\View */
?>
<div class="col-lg-9">
<div class="box box-info">
<div class="box-header" style="padding: 10px;">
Product :
<?php
echo AutoComplete::widget(['name' => 'product', 'id' => 'product', 'clientOptions' => ['source' => new JsExpression('yii.global.sourceProduct'), 'select' => new JsExpression('yii.purchase.onProductSelect'), 'delay' => 100], 'options' => ['style' => 'width:350px;']]);
?>
<div class="pull-right">
Item Discount:
<?php
echo Html::activeTextInput($model, 'item_discount', ['style' => 'width:60px;', 'id' => 'item-discount']);
?>
</div>
</div>
<div class="box-body" style="text-align: right;">
<?php
echo Html::activeHiddenInput($model, 'purchase_value', ['id' => 'purchase-value']);
?>
<h4 id="bfore" style="display: none;">Rp <span id="purchase-val">0</span>-<span id="disc-val">0</span></h4>
<h2>Rp <span id="total-price"></span></h2>
</div>
示例13: JsExpression
$icons = ['nuevo' => '<span class="glyphicon glyphicon-file" aria-hidden="true"></span>', 'crear' => '<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>', 'editar' => '<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>', 'eliminar' => '<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>', 'volver' => '<span class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>'];
?>
<div class="materiales-servicios-form">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'id_se')->hiddenInput();
?>
<div class="form-group">
<?php
echo AutoComplete::widget(['model' => $model, 'name' => 'subEspecifica', 'options' => ['class' => 'form-control', 'placeholder' => 'Escriba para buscar'], 'clientOptions' => ['source' => $sub_especfica, 'autoFill' => true, 'select' => new JsExpression("function(event, ui) {\n \$('#materialesservicios-id_se').val(ui.item.id);\n }")]]);
?>
</div>
<?php
echo $form->field($model, 'nombre')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'unidad_medida')->dropDownList(ArrayHelper::map($unidad_medida, 'id', 'unidad_medida'), ['prompt' => 'Seleccione']);
?>
<?php
echo $form->field($model, 'presentacion')->dropDownList(ArrayHelper::map($presentacion, 'id', 'nombre'), ['prompt' => 'Seleccione']);
?>
示例14: JsExpression
<?php
echo $form->field($model, 'sales_num')->textInput(['readonly' => true]);
?>
<?php
echo $form->field($model, 'id_warehouse')->dropDownList(Helper::getWarehouseList());
?>
<?php
echo $form->field($model, 'salesDate')->widget('yii\\jui\\DatePicker', ['options' => ['class' => 'form-control', 'style' => 'width:50%'], 'clientOptions' => ['dateFormat' => 'dd-mm-yy']]);
?>
<hr >
<?php
$id_input = Html::getInputId($model, 'id_customer');
$field = $form->field($model, 'id_customer', ['template' => "{label}\n{input}\n{text}\n{hint}\n{error}"]);
$field->labelOptions['for'] = $id_input;
$field->input('hidden', ['id' => 'id_customer']);
$field->parts['{text}'] = AutoComplete::widget(['model' => $model, 'attribute' => 'idCustomer[nm_cust]', 'options' => ['class' => 'form-control', 'id' => $id_input], 'clientOptions' => ['source' => new JsExpression('yii.standart.sourceCustomer'), 'select' => new JsExpression('yii.standart.onCustomerSelect'), 'open' => new JsExpression('yii.standart.onCustomerOpen')]]);
echo $field;
?>
<?php
echo $form->field($model, 'discount')->textInput();
?>
</div>
</div>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
</div>
<?php
ActiveForm::end();
示例15: run
public function run()
{
\yii\jui\AutoComplete::widget();
parent::run();
}