本文整理汇总了PHP中yii\bootstrap\Html::textInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::textInput方法的具体用法?PHP Html::textInput怎么用?PHP Html::textInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Html
的用法示例。
在下文中一共展示了Html::textInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @inheritdoc
*/
public function run()
{
parent::init();
ListInputAsset::register($this->view);
$pluginOptions = Json::encode($this->pluginOptions);
$this->view->registerJs(sprintf('$("#%s").listinput(%s)', $this->options['id'], $pluginOptions));
if ($this->hasModel()) {
if ($this->form == null) {
throw new InvalidConfigException(__CLASS__ . '::$form must be specifed.');
}
return $this->form->field($this->model, $this->attribute, ['template' => $this->template])->textInput($this->options);
} else {
return Html::textInput($this->name, $this->value, $this->options);
}
}
示例2: reset
</p>
</div>
<div class="row" style="margin-top: 15pt;">
<div class="col-md-10 inline-form-selector">
<?php
if (!is_array($model)) {
?>
<?php
echo Html::activeTextInput($model, 'nsips', ['class' => 'form-control', 'placeholder' => $model->getAttributeLabel('nameservers'), 'autocomplete' => 'off']);
?>
<?php
} else {
?>
<?php
echo Html::textInput('nsips', '', ['class' => 'form-control', 'placeholder' => reset($model)->getAttributeLabel('nameservers'), 'autocomplete' => 'off']);
?>
<?php
}
?>
</div>
<div class="col-md-2 text-right">
<?php
echo Html::submitButton(Yii::t('hipanel', 'Save'), ['class' => 'btn btn-success', 'id' => 'nss-save-button', 'data-loading-text' => '<i class="fa fa-circle-o-notch fa-spin"></i> ' . Yii::t('hipanel', 'saving')]);
?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<hr>
示例3:
use yii\helpers\Url;
use yii\widgets\LinkPager;
use frontend\components\Common;
?>
<div class="properties-listing spacer">
<div class="row">
<div class="col-lg-3 col-sm-4 ">
<?php
echo Html::beginForm(Url::to('main/main/find'), 'get');
?>
<div class="search-form"><h4><span class="glyphicon glyphicon-search"></span> Search for</h4>
<!--<input type="text" class="form-control" placeholder="Search of Properties">-->
<?php
echo Html::textInput('search', '', ['class' => 'form-control', 'placeholder' => 'Search of Properties']);
?>
<div class="row">
<div class="col-lg-5">
<select class="form-control">
<option>Buy</option>
<option>Rent</option>
<option>Sale</option>
</select>
</div>
<div class="col-lg-7">
<?php
echo Html::dropDownList('price', '', ['150000-200000' => '$150,000 - $200,000', '200000-250000' => '$200,000 - $250,000', '250000-300000' => '$250,000 - $300,000', '300000' => '$300,000 - above'], ['class' => 'form-control', 'prompt' => 'Price']);
?>
</div>
</div>
示例4: renderHtmlInput
public function renderHtmlInput($input_type_id, $options = [])
{
$field = $options['prefix_text'] . " ";
switch ($input_type_id) {
case Types::$input_type['small_text']['id']:
$field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:60px']);
break;
case Types::$input_type['med_text']['id']:
$field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', []);
break;
case Types::$input_type['large_text']['id']:
$field .= Html::textInput(sprintf('question_%s', $options['screening_question_id']), '', ['style' => 'width:240px']);
break;
case Types::$input_type['date']['id']:
$field = sprintf('');
break;
case Types::$input_type['radio']['id']:
// Enable tristate behavior with custom indeterminate value, custom toggle icon, and a custom label for the indeterminate state.
$options['tristate_option_id'] == Types::$boolean['true']['id'] ? $tristate = true : ($tristate = false);
$field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [Types::$boolean['true']['description'] => Types::$boolean['true']['description'], Types::$boolean['false']['description'] => Types::$boolean['false']['description']], ['unselect' => Types::$boolean['null']['description'], 'separator' => ' ']);
break;
case Types::$input_type['text_agreement']['id']:
case Types::$input_type['text_agreement']['id']:
$field = Html::radioList(sprintf('question_%s', $options['screening_question_id']), Types::$boolean['null']['id'], [yii::t('app', 'Agree') => yii::t('app', 'Agree'), yii::t('app', 'Disagree') => yii::t('app', 'Disagree')], ['unselect' => Types::$boolean['null']['description'], 'separator' => ' ']);
break;
break;
case Types::$input_type['image_overlay']['id']:
$field = sprintf('image overlay');
break;
}
$field .= " " . $options['suffix_text'];
return $field;
}
示例5: run
public function run()
{
echo Html::beginTag('div', ['class' => 'input-group']);
if (!isset($this->options['class'])) {
$this->options['class'] = 'form-control';
}
$iconId = 'icon-' . $this->options['id'];
if (!isset($this->options['aria-describedby'])) {
$this->options['aria-describedby'] = $iconId;
}
if ($this->hasModel()) {
$replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
}
if ($this->icon != '') {
$replace['{icon}'] = Html::tag('span', Icon::show($this->icon, [], Icon::FA), ['class' => 'input-group-addon', 'id' => $iconId]);
}
echo strtr($this->template, $replace);
echo Html::endTag('div');
$view = $this->getView();
Assets::register($view);
$idMaster = $this->hasModel() ? Html::getInputId($this->model, $this->fromField) : $this->fromField;
$idSlave = $this->options['id'];
$view->registerJs("\n \$('#{$idMaster}').syncTranslit({\n destination: '{$idSlave}',\n type: 'url',\n caseStyle: 'lower',\n urlSeparator: '-'\n });");
}
示例6: renderDataCellContent
/**
* @inheritDoc
*/
protected function renderDataCellContent($model, $key, $index)
{
/**
* @var ISortableActiveRecord|ActiveRecord $model
*/
Yii2::assertType($model, ActiveRecord::class, ISortableActiveRecord::class);
if (!$this->editable) {
return $model->getSortBehavior()->getValue();
} else {
return Html::textInput($model->getSortBehavior()->attributeName, $model->getSortBehavior()->getValue(), $this->inputOptions);
}
}
示例7: run
/**
* @inheritdoc
*/
public function run()
{
parent::init();
if (!isset($this->pluginOptions['monthNames'])) {
$this->pluginOptions = ArrayHelper::merge($this->pluginOptions, ['monthNames' => $this->getMonthNames()]);
}
if (!isset($this->pluginOptions['template'])) {
$this->pluginOptions = ArrayHelper::merge($this->pluginOptions, ['template' => $this->getTemplate()]);
}
BirthdayPickerAsset::register($this->view);
$pluginOptions = Json::encode($this->pluginOptions);
$this->view->registerJs(sprintf('$("#%s").birthdayPicker(%s)', $this->options['id'], $pluginOptions));
if ($this->hasModel()) {
if ($this->form == null) {
throw new InvalidConfigException(__CLASS__ . '::$form must be specifed.');
}
return $this->form->field($this->model, $this->attribute, ['template' => $this->template])->textInput($this->options);
} else {
return Html::textInput($this->name, $this->value, $this->options);
}
}
示例8: settingField
/**
* @param $item
* @return string
*/
public static function settingField($key, $item, $traslateCategory)
{
$return = '';
switch ($item['type']) {
case 'checkbox':
$return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::hiddenInput('Settings[' . $key . ']', 0) . \oakcms\bootstrapswitch\Switcher::widget(['id' => 'wid' . uniqid(), 'name' => 'Settings[' . $key . ']', 'checked' => $item['value']]) . parent::endTag('div') . parent::endTag('div');
break;
case 'textInput':
$return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::textInput('Settings[' . $key . ']', $item['value'], ['class' => 'form-control']) . parent::endTag('div') . parent::endTag('div');
break;
case 'textarea':
$return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::textarea('Settings[' . $key . ']', $item['value'], ['class' => 'form-control']) . parent::endTag('div') . parent::endTag('div');
break;
case 'mediaInput':
$return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . InputFile::widget(['id' => 'wid' . uniqid(), 'language' => \Yii::$app->language, 'filter' => 'image', 'name' => 'Settings[' . $key . ']', 'value' => $item['value']]) . parent::endTag('div') . parent::endTag('div');
break;
default:
$return = '';
break;
}
return $return;
}
示例9:
<?php
Pjax::begin(['enablePushState' => false, 'id' => 'begin-term']);
$form = ActiveForm::begin(['id' => 'begin-graduate-form', 'options' => ['class' => 'form-horizontal', 'data-pjax' => true]]);
?>
<div class="form-group">
<?php
echo Html::label('Изменить название');
?>
<div class="input-group ">
<span class="input-group-addon">
<?php
echo Html::radio('source', true, ['value' => 'edit']);
?>
</span>
<?php
echo Html::textInput('editName', $model->workTitle ? $model->workTitle->name : null, ['class' => 'form-control']);
?>
</div>
</div>
<?php
/* if($model->reserved_id != null) { ?>
<div class="form-group">
<?=Html::label('Создать новую тему'); ?>
<div class="input-group ">
<span class="input-group-addon">
<?=Html::radio('source',false,['value' => 'new'])?>
</span>
<?=Html::textInput('newName',null,['class' => 'form-control']); ?>
</div>
</div>
示例10: generateHtml
/**
* @param $xmlRow
* @param $settings
* @param bool $place
* @return string
*/
private function generateHtml($xmlRow, $settings, $place = false)
{
$html = "";
$button_option = $xmlRow['field'];
//Проверка "отображать" или нет элемент
if (isset($button_option[6]['@attributes']['value']) && $button_option[6]['@attributes']['value'] == "0") {
return $html;
}
$html .= \yii\bootstrap\Html::beginTag("div", ['class' => 'row form-group']);
$html .= \yii\bootstrap\Html::beginTag("div", ['class' => 'col-xs-6']);
$html .= isset($place[1]) ? str_replace("#place#", $place[1], $button_option[4]['@attributes']['value']) : $button_option[4]['@attributes']['value'];
$html .= \yii\bootstrap\Html::endTag("div");
$html .= \yii\bootstrap\Html::beginTag("div", ['class' => 'col-xs-6']);
$fieldName = isset($place[0]) ? $place[0] . $button_option[0]['@attributes']['value'] : $button_option[0]['@attributes']['value'];
$elProperty = array();
//Проверка "разрешить" редактирование или нет
if ($button_option[5]['@attributes']['value'] == "0") {
$elProperty["disabled"] = "disabled";
}
//Проверка "отображать" или нет элемент
if (isset($button_option[6]['@attributes']['value']) && $button_option[6]['@attributes']['value'] == "0") {
$elProperty["style"] = "display:none";
}
//Дополнительные атрибуты
if ($button_option[1]['@attributes']['value'] == "text") {
$elProperty["size"] = 50;
}
switch ($button_option[1]['@attributes']['value']) {
case 'text':
$match = array();
preg_match("/#(.*)#/i", $button_option[2]['@attributes']['value'], $match);
$value = isset($match[1]) && !empty($match[1]) ? eval($match[1]) : $button_option[2]['@attributes']['value'];
$html .= \yii\bootstrap\Html::textInput($fieldName, isset($settings[$fieldName]) ? $settings[$fieldName] : $value, $elProperty);
break;
case 'select':
$select = json_decode($button_option[3]['@attributes']['value'], true);
$html .= \yii\bootstrap\Html::dropDownList($fieldName, isset($settings[$fieldName]) ? $settings[$fieldName] : $button_option[2]['@attributes']['value'], $select, $elProperty);
break;
}
$html .= \yii\bootstrap\Html::endTag("div");
$html .= \yii\bootstrap\Html::endTag("div");
return $html;
}
示例11: renderField
public static function renderField($group, $fieldName, $fieldParams)
{
$id = $fieldParams['id'];
$type = $fieldParams['type'];
$value = $fieldParams['value'];
$description = $fieldParams['description'];
$options = $fieldParams['options'];
$fld = $group . '[' . $fieldName . ']';
$html = '';
switch ($type) {
case 'text':
$html .= self::labelInput($fieldName, $fld, Html::textInput($fld, $value, ['class' => 'form-control']));
$html .= self::hint($description);
break;
case 'textarea':
$html .= self::labelInput($fieldName, $fld, Html::textarea($fld, $value, ['rows' => 5, 'class' => 'form-control', 'hint' => $description]));
$html .= ConfigurationUtils::hint($description);
break;
case 'checkbox':
$html .= self::labelInput($fieldName, $fld, Html::checkbox($fld, $value, ['value' => $value == '1' ? '1' : '0', 'class' => 'form-control autoval']));
break;
case 'dropdown':
$data = explode(",", $options);
$data = array_reverse($data);
$data[''] = Yii::t('app', 'Select an option...');
$data = array_reverse($data);
$data = array_combine($data, $data);
$html .= self::labelInput($fieldName, $fld, Html::dropDownList($fld, $value, $data, ['class' => 'form-control']));
break;
}
return $html;
}
示例12: function
<?php
use yii\bootstrap\Modal;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\bootstrap\Html;
use sya\ecommerce\Ecommerce;
$ecommerce = Ecommerce::module();
// Declare column in product
$defaultColumns = [['attribute' => '_id', 'hAlign' => 'center', 'vAlign' => 'middle', 'contentOptions' => ['class' => 'productId']]];
$productColumns = ArrayHelper::merge($defaultColumns, $productColumns);
$productColumns[] = ['header' => Yii::t('ecommerce', 'Quantity'), 'hAlign' => 'center', 'vAlign' => 'middle', 'contentOptions' => ['class' => 'productQty'], 'value' => function ($model, $key, $index, $widget) use($ecommerce) {
$options = ['class' => 'form-control qty_' . $model->_id];
if ($ecommerce->multiple) {
$options['onkeyup'] = 'return productQtyOrder(this);';
} else {
$options['readonly'] = '';
}
return Html::textInput('qty', 1, $options);
}, 'format' => 'raw'];
// Modal product
Modal::begin(['id' => 'product_modal', 'size' => 'modal-lg', 'header' => '<h4 class="modal-title" id="myModalLabel">' . Yii::t('ecommerce', 'List Product') . '</h4>', 'toggleButton' => ['label' => '<i class="fa fa-plus"></i> ' . Yii::t('ecommerce', 'Create') . ' ' . Yii::t('ecommerce', 'Product'), 'class' => 'btn btn-xs btn-primary pull-right'], 'footer' => '<button type="button" onclick="addProduct();" class="btn btn-primary">' . Yii::t('ecommerce', 'Create') . ' ' . Yii::t('ecommerce', 'Product') . '</button>']);
echo GridView::widget(['panel' => ['heading' => Yii::t('ecommerce', 'Product')], 'id' => 'product-grid', 'pjax' => TRUE, 'dataProvider' => $productDataProvider, 'filterModel' => $productSearchModel, 'columns' => $productColumns, 'responsive' => true, 'hover' => true, 'toolbar' => []]);
Modal::end();
echo Html::hiddenInput('product_list', \sya\ecommerce\Module::getProductList($model->product), ['id' => 'product_list']);
echo Html::hiddenInput(\yii\helpers\StringHelper::basename(get_class($model)) . '[product_text]', $model->product_text, ['id' => 'product_text']);
// Register js code
$this->registerJs("\r\n // Add or remove product when click product\r\n function productOrder(){\r\n \$('#product-grid-container table tbody tr').click(function(){\r\n // Get id of product and qty\r\n var id = \$(this).find('.productId').text();\r\n var qty = \$(this).find('.productQty input');\r\n \r\n // Get id and qty selected\r\n var product_list = new Array();\r\n if(\$('#product_list').val()){\r\n var productSelected = \$('#product_list').val().split(',');\r\n }else{\r\n var productSelected = null;\r\n }\r\n \r\n if(\$(this).hasClass('selected')){ // remove from hidden field\r\n removeProductId(productSelected, product_list, id, qty, this);\r\n } else { // add too hidden field\r\n addProductId(productSelected, product_list, id, qty, this);\r\n }\r\n });\r\n }\r\n \r\n // Add or remove product when qty = 0\r\n function productQtyOrder(element){\r\n // Get id of product and qty\r\n var id = \$(element).parent().parent().find('.productId').text();\r\n var qty = \$(element);\r\n \r\n // Get id and qty selected\r\n var product_list = new Array();\r\n if(\$('#product_list').val()){\r\n var productSelected = \$('#product_list').val().split(',');\r\n }else{\r\n var productSelected = null;\r\n }\r\n\r\n if(qty.val() == 0){ // remove from hidden field\r\n removeProductId(productSelected, product_list, id, qty, \$(element).parent().parent());\r\n } else { // add too hidden field\r\n addProductId(productSelected, product_list, id, qty, \$(element).parent().parent());\r\n }\r\n }\r\n \r\n // Function remove id product\r\n function removeProductId(productSelected, product_list, id, qty, element){\r\n if(productSelected.length){\r\n j = 0;\r\n for(i =0;i< productSelected.length;i++){\r\n info = productSelected[i].split(':');\r\n if(info[0]!=id){\r\n product_list[j] = info[0]+':'+info[1];\r\n j++;\r\n }\r\n }\r\n }\r\n\r\n \$('#product_list').val(product_list.length?product_list.join():'');\r\n \$(element).removeClass('selected');\r\n qty.val(0);\r\n }\r\n \r\n // Function add id product\r\n function addProductId(productSelected, product_list, id, qty, element){\r\n if (qty.val() == 0) qty.val(1);\r\n \$(element).addClass('selected');\r\n\r\n if(productSelected){\r\n updateValue = false;\r\n for(i =0;i< productSelected.length;i++){\r\n info = productSelected[i].split(':');\r\n if(info[0]==id){\r\n product_list[i] =info[0]+':'+qty.val();\r\n updateValue = true;\r\n }else{\r\n product_list[i]=info[0]+':'+info[1];\r\n }\r\n }\r\n if(!updateValue){\r\n product_list[product_list.length] = id+':'+qty.val();\r\n }\r\n }\r\n \$('#product_list').val(product_list.length?product_list.join():(id+':'+qty.val()));\r\n }\r\n \r\n // Selected product\r\n function setSelect(){\r\n var product_list = \$('#product_list').val();\r\n if(product_list){\r\n var field = product_list.split(',');\r\n var total = field.length;\r\n for(var i=0; i<total; i++){\r\n var product = field[i].split(':');\r\n \$('.qty_'+product[0]).val(product[1]);\r\n \$('.qty_'+product[0]).parent().parent().addClass('selected');\r\n }\t\t\r\n }\r\n }\r\n \r\n // Add product in order\r\n function addProduct(){\r\n var shipping = \$('#syaShipping').val();\r\n \$.ajax({\r\n url: '" . \yii\helpers\Url::to(['/ecommerce/ajax/addproduct']) . "',\r\n type: 'post',\r\n dataType: 'json',\r\n data: {data: \$('#product_list').val(), shipping: shipping},\r\n }).done(function (data) {\r\n \$('#product_info').html(data.template);\r\n \$('#product_text').val(data.titles);\r\n totalProduct();\r\n \$('#product_modal').modal('hide');\r\n });\r\n }\r\n", yii\web\View::POS_END);
$this->registerJs("\r\n productOrder();\r\n setSelect();\r\n \$(document).on('pjax:complete', function () {\r\n productOrder();\r\n setSelect();\r\n });\r\n", yii\web\View::POS_READY);
示例13:
<div id="forgotPasswordMessage"></div>
<div id="forgotPasswordLoading" style="display: none"><?php
echo Yii::t('app', 'Checking your username...');
?>
</div>
<div id="forgotPasswordForm">
<p><?php
echo Yii::t('app', 'Enter your email address in the box below and click the button "Send me the password". We will send a link to reset your password.');
?>
</p>
<?php
ActiveForm::begin(['action' => \yii\helpers\Url::to(['shopcart/forgot-password']), 'id' => 'formForgotPassword']);
?>
<?php
echo Html::textInput('username', '', ['class' => 'input-username form-control input-lg', 'placeholder' => Yii::t('app', 'Email address')]);
?>
<?php
ActiveForm::end();
?>
</div>
</div>
<div class="modal-footer">
<button type="button" id="sc-forgot-password-cancel" class="btn btn-default" data-dismiss="modal"><?php
echo Yii::t('app', 'Close');
?>
</button>
<button type="button" id="sc-forgot-password" class="btn btn-primary"><?php
echo Yii::t('app', 'Send me the password');
?>
示例14:
<?php
use frontend\packages\AdminAsset;
use yii\bootstrap\Html;
AdminAsset::register($this);
?>
<p> </p>
<p> </p>
<div class="row">
<div class="col-sm-6-offset col-sm-offset-2 col-md-7 col-md-offset-2 main">
<div id='search-user'>
<?php
echo Html::textInput('search', '', ['id' => 'searchUser']);
?>
<?php
echo Html::submitButton('Search University system', ['onClick' => '$.app.page.ldapSearchUser()']);
?>
</div>
<br />
<div id='div-display-user' style='display:none'>
<table class="table table-bordered">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th> </th>
示例15: function
<?php
use yii\bootstrap\Modal;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\bootstrap\Html;
// Declare column in product
$defaultColumns = [['attribute' => '_id', 'hAlign' => 'center', 'vAlign' => 'middle', 'contentOptions' => ['class' => 'productId']]];
$productColumns = ArrayHelper::merge($defaultColumns, $productColumns);
$productColumns[] = ['header' => Yii::t('ecommerce', 'Quantity'), 'hAlign' => 'center', 'vAlign' => 'middle', 'contentOptions' => ['class' => 'productQty'], 'value' => function ($model, $key, $index, $widget) {
return Html::textInput('qty', 0, ['class' => 'form-control qty_' . $model->_id, 'onkeyup' => 'return productQtyOrder(this);']);
}, 'format' => 'raw'];
// Modal product
Modal::begin(['id' => 'product_modal', 'size' => 'modal-lg', 'header' => '<h4 class="modal-title" id="myModalLabel">' . Yii::t('ecommerce', 'List Product') . '</h4>', 'toggleButton' => ['label' => '<i class="fa fa-plus"></i> ' . Yii::t('ecommerce', 'Add') . ' ' . Yii::t('ecommerce', 'Product'), 'class' => 'btn btn-xs btn-primary pull-right'], 'footer' => '<button type="button" onclick="addProduct();" class="btn btn-primary">' . Yii::t('ecommerce', 'Add Product') . '</button>']);
echo GridView::widget(['panel' => ['heading' => Yii::t('product', 'Product')], 'id' => 'product-grid', 'pjax' => TRUE, 'dataProvider' => $productDataProvider, 'filterModel' => $productSearchModel, 'columns' => $productColumns, 'responsive' => true, 'hover' => true, 'toolbar' => []]);
Modal::end();
echo Html::hiddenInput('product_list', \sya\ecommerce\Module::getProductList($model->product), ['id' => 'product_list']);
// Register js code
$this->registerJs("\r\n // Add or remove product when click product\r\n function productOrder(){\r\n \$('#product-grid-container table tbody tr').click(function(){\r\n // Get id of product and qty\r\n var id = \$(this).find('.productId').text();\r\n var qty = \$(this).find('.productQty input');\r\n \r\n // Get id and qty selected\r\n var product_list = new Array();\r\n if(\$('#product_list').val()){\r\n var productSelected = \$('#product_list').val().split(',');\r\n }else{\r\n var productSelected = null;\r\n }\r\n \r\n if(\$(this).hasClass('selected')){ // remove from hidden field\r\n removeProductId(productSelected, product_list, id, qty, this);\r\n } else { // add too hidden field\r\n addProductId(productSelected, product_list, id, qty, this);\r\n }\r\n });\r\n }\r\n \r\n // Add or remove product when qty = 0\r\n function productQtyOrder(element){\r\n // Get id of product and qty\r\n var id = \$(element).parent().parent().find('.productId').text();\r\n var qty = \$(element);\r\n \r\n // Get id and qty selected\r\n var product_list = new Array();\r\n if(\$('#product_list').val()){\r\n var productSelected = \$('#product_list').val().split(',');\r\n }else{\r\n var productSelected = null;\r\n }\r\n\r\n if(qty.val() == 0){ // remove from hidden field\r\n removeProductId(productSelected, product_list, id, qty, \$(element).parent().parent());\r\n } else { // add too hidden field\r\n addProductId(productSelected, product_list, id, qty, \$(element).parent().parent());\r\n }\r\n }\r\n \r\n // Function remove id product\r\n function removeProductId(productSelected, product_list, id, qty, element){\r\n if(productSelected.length){\r\n j = 0;\r\n for(i =0;i< productSelected.length;i++){\r\n info = productSelected[i].split(':');\r\n if(info[0]!=id){\r\n product_list[j] = info[0]+':'+info[1];\r\n j++;\r\n }\r\n }\r\n }\r\n\r\n \$('#product_list').val(product_list.length?product_list.join():'');\r\n \$(element).removeClass('selected');\r\n qty.val(0);\r\n }\r\n \r\n // Function add id product\r\n function addProductId(productSelected, product_list, id, qty, element){\r\n if (qty.val() == 0) qty.val(1);\r\n \$(element).addClass('selected');\r\n\r\n if(productSelected){\r\n updateValue = false;\r\n for(i =0;i< productSelected.length;i++){\r\n info = productSelected[i].split(':');\r\n if(info[0]==id){\r\n product_list[i] =info[0]+':'+qty.val();\r\n updateValue = true;\r\n }else{\r\n product_list[i]=info[0]+':'+info[1];\r\n }\r\n }\r\n if(!updateValue){\r\n product_list[product_list.length] = id+':'+qty.val();\r\n }\r\n }\r\n \$('#product_list').val(product_list.length?product_list.join():(id+':'+qty.val()));\r\n }\r\n \r\n // Selected product\r\n function setSelect(){\r\n var product_list = \$('#product_list').val();\r\n if(product_list){\r\n var field = product_list.split(',');\r\n var total = field.length;\r\n for(var i=0; i<total; i++){\r\n var product = field[i].split(':');\r\n \$('.qty_'+product[0]).val(product[1]);\r\n \$('.qty_'+product[0]).parent().parent().addClass('selected');\r\n }\t\t\r\n }\r\n }\r\n \r\n // Add product in order\r\n function addProduct(){\r\n var shipping = \$('#syaShipping').val();\r\n \$.ajax({\r\n url: '" . \yii\helpers\Url::to(['/ecommerce/ajax/addproduct']) . "',\r\n type: 'post',\r\n data: {data: \$('#product_list').val(), shipping: shipping},\r\n }).done(function (data) {\r\n \$('#product_info').html(data);\r\n totalProduct();\r\n \$('#product_modal').modal('hide');\r\n });\r\n }\r\n", yii\web\View::POS_END);
$this->registerJs("\r\n productOrder();\r\n setSelect();\r\n \$(document).on('pjax:complete', function () {\r\n productOrder();\r\n setSelect();\r\n });\r\n", yii\web\View::POS_READY);