How to hide history dropdown list in Yii2 kartik select2?
This is my source code:
<div class="col-sm-offset-2 col-sm-10" style="margin-left:135px;margin-bottom:15px">
<label class="control-label">Range Perjalanan Dinas</label>
<?= DatePicker::widget([
'type' => DatePicker::TYPE_RANGE,
'model' => $model,
'attribute' => 'tgl_mulai',
'attribute2' => 'tgl_selesai',
'options' => ['placeholder' => 'Start date'],
'options2' => ['placeholder' => 'End date'],
'form' => $form,
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'autoclose' => true,
]
]); ?>
</div>
Try 'autocomplete' => 'off' in your date picker options:
<?= DatePicker::widget([
'type' => DatePicker::TYPE_RANGE,
'model' => $model,
'attribute' => 'tgl_mulai',
'attribute2' => 'tgl_selesai',
'options' => ['placeholder' => 'Start date','autocomplete' => 'off'],
'options2' => ['placeholder' => 'End date'],
'form' => $form,
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'autoclose' => true,
]
]); ?>
You may have to turn off the autocomplete in your form element
Turning off form autocomplete
Related
<?= GridView::widget([
'id' => 'CompanyGrid',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'floatHeader'=>true,
'floatOverflowContainer'=>true,
'floatHeaderOptions'=>['top'=>'0'],
'pjax'=>true,
'pjaxSettings' => [
'options' => [
'enablePushState' => false,
'enableReplaceState' => true,
]
],
'hover'=>true,
'toolbar' => [
'{export}',
'{toggleData}'
],
'panel' => [
'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> Companies</h3>',
'type'=>'secondary',
'before'=>Html::button('Create Company', ['value'=>Url::to('index.php?r=Company/company/create'), 'title' => 'Create Company', 'class' => 'btn btn-success', 'id' => 'modalButton']),
'after'=>false,
],
'columns' => [
['class' => 'kartik\grid\SerialColumn'],
'CompanyID',
'CompanyName',
['class' => 'kartik\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'buttons' => [
'view' => function($url, $model){
return Html::a('<span class="fa fa-eye"></span>', ['view', 'id' => $model->CompanyID], [
'class' => 'activity-view-link',
'data-pjax'=>'w0',
'title' => Yii::t('yii', 'View Company: '.$model->CompanyID),
'data-toggle' => 'modal',
'data-target' => '#modal',
]);
},
'update' => function($url, $model){
return Html::a('<span class="fa fa-edit"></span>', ['update', 'id' => $model->CompanyID], [
'class' => 'activity-view-link',
'title' => Yii::t('yii', 'Edit Company: '.$model->CompanyID),
'data-toggle' => 'modal',
'data-target' => '#modal',
]);
},
'delete' => function($url, $model){
return Html::a('<span class="fa fa-trash"></span>', ['delete', 'id' => $model->CompanyID], [
'class' => '',
'data' => [
'confirm' => 'Are you absolutely sure? This action is not reversible',
'method' => 'post',
],
]);
}
],
],
],
]); ?>
In Controller
public function actionView($id)
{
$model = Company::findOne($id);
return $this->renderAjax('view', [
'model' => $model,
]);
}
I am new in yii2-advance-apps and i am trying to solve this problem. Already worked on this problem and cannot find any solution for this.
The problem is when I click on the gridview actions buttons, it works. However, after PJax, the button just don't work anymore.
However, if i reload the page, the button works again.
How to solve this problem. Thank you in advance.
'data-pjax' => 0, in action buttons options and not 'w0'
I have this gridview
I want to replace the blank space on the status with All, so that it will have All, Active, Inactive
View:Gridview
[
'class' => '\pheme\grid\ToggleColumn',
'contentOptions' => ['class' => 'text-center'],
'attribute'=>'is_status',
'enableAjax' => false,
'filter'=>['1'=>'InActive', '0'=>'Active'],
],
How do I achieve this?
Use filterInputOptions
[
'class' => '\pheme\grid\ToggleColumn',
'contentOptions' => ['class' => 'text-center'],
'attribute' => 'is_status',
'enableAjax' => false,
'filter' => ['1' => 'InActive', '0' => 'Active'],
'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => 'All'],
],
I'm printing gridview in pdf. The gridview is fine. But the cells are not filling in properly. I think if I can decrease the font a bit, the cell will be filled in properly. I've decreased the width. But the cells are being distorted.
Code of Gridview -
<?= GridView::widget([
'dataProvider' => $dataProvider1,
//'filterModel' => $searchModel,
'layout'=>"{items}",
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'hsncode',
[
'label' => 'Productname',
'attribute' =>'productname',
'headerOptions' => ['style' => 'width:20%'],
//'contentOptions' => ['class' => 'col-lg-1'],
//'format'=>['decimal',2]
],
'batchno',
//'expdate',
[
'attribute'=>'expdate',
'format'=>['DateTime','php:m-y'],
'headerOptions' => ['style' => 'width:6%'],
],
'mrp',
'rate',
'qty',
'free',
'discount',
[
'label' => 'Value',
'attribute' =>'value',
//'contentOptions' => ['class' => 'col-lg-1'],
'format'=>['decimal',2]
],
[
'label' => 'GST%',
'attribute' =>'gstpercent',
//'headerOptions' => ['style' => 'width:6%'],
//'contentOptions' => ['class' => 'col-lg-1'],
'format'=>['decimal',0]
],
[
'label' => 'Total',
'attribute' =>'totalamount',
'headerOptions' => ['style' => 'width:9%'],
//'contentOptions' => ['class' => 'col-lg-1'],
'format'=>['decimal',2]
],
],
]); ?>
Gridview looks like -
Please let me know how to specify the font in gridview.
you could use options for the grid container
<?= GridView::widget([
'dataProvider' => $dataProvider1,
//'filterModel' => $searchModel,
'layout'=>"{items}",
'options' => ['style' => 'font-size:12px;']
'columns' => [
or directly in column
<?= GridView::widget([
'dataProvider' => $dataProvider1,
//'filterModel' => $searchModel,
'layout'=>"{items}",
'options' => ['style' => 'font-size:12px;']
'columns' => [
[
'label' => 'your_label',
'attribute' =>'your_attribute',
'contentOptions' => ['style' => 'font-size:12px;']
]
I want to show dates which are greater than current date
in ValidFrom and dates greater than ValidFrom in ValidUpto field but unable to show.I want hide previous dates in date picker.
My code is below.
echo DatePicker::widget([
'model' => $model,
'attribute' => 'ValidFrom',
'attribute2' => 'ValidUpto',
'options' => ['placeholder' => 'valid from',
],
'options2' => ['placeholder' => 'valid to'],
'type' => DatePicker::TYPE_RANGE,
'form' => $form,
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'autoclose' => true,
],
]);
Add a id attribute to the date picker:
echo DatePicker::widget([
'id'=>'mydatepicker',
'model' => $model,
'attribute' => 'ValidFrom',
'attribute2' => 'ValidUpto',
'options' => ['placeholder' => 'valid from',
],
'options2' => ['placeholder' => 'valid to'],
'type' => DatePicker::TYPE_RANGE,
'form' => $form,
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'autoclose' => true,
],
]);
Set minDate to the date picker in your view file:
<?
$script = <<< JS
$( "#mydatepicker").datepicker({dateFormat: "yyyy-mm-dd", minDate: 0});
JS;
$this->registerJs($script, View::POS_END);
?>
I am using kartik datepicker extension http://demos.krajee.com/widget-details/datepicker in Yii2.
Issue :
If I use this with custom id for input it does not show show model validations
echo kartik\date\DatePicker::widget([
'model' => $objPatientModel,
'form'=>$objActiveForm,
'attribute' => 'date_of_birth',
'options' => ['placeholder' => 'Enter birth date ...', 'id' => 'patient_dob'], **// with id clientside validations for model does not work**
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'endDate' => date('d-m-Y'),
]
]);
While below code works
echo kartik\date\DatePicker::widget([
'model' => $objPatientModel,
'form'=>$objActiveForm,
'attribute' => 'date_of_birth',
'options' => ['placeholder' => 'Enter birth date ...'],**//id is not used here**
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'endDate' => date('d-m-Y'),
]
]);
But I want to use custom id .Any suggestions ?
You have to override the selectors, example:
$form->field($model, 'comment', ['selectors' => ['input' => '#myCustomId']])
->textarea(['id' => 'myCustomId']);?>
See https://github.com/yiisoft/yii2/issues/7627
<?=
$form->field($model, 'sales_date')->widget(DateControl::classname(), [
'name' => 'sales_date',
'value' => date('d-m-Y h:i:s'),
'type' => DateControl::FORMAT_DATETIME,
'autoWidget' => true,
'displayFormat' => 'php:d-m-Y h:i:s',
'saveFormat' => 'php:Y-m-d h:i:s',
'saveOptions' => [
'type' => 'hidden',
'form' => 'sales-form-red',
],
])
?>
by using the following option you can add extra form tag to input
'saveOptions' => [
'type' => 'hidden',
'form' => 'sales-form-red',
'class' => 'sales_date',
]
In my case out was
<input type="hidden" id="sales-sales_date" name="Sales[sales_date]" form="sales-form-red">
check by using link
Date Control Demo