My code is:
<?= $form->field($model, 'imageFiles[]')->widget(FileInput::classname(), [
'options' => ['multiple' => true, 'accept' => 'image/*', 'id'=>'inputFile'],
'pluginOptions' => [
'rtl'=>'true',
'fileActionSettings'=>['showZoom'=>true, 'showRemove' =>true,
'showDrag'=>true],
previewFileType' => 'image',
'maxFileCount' => 4,
'showUpload' => false,
],
]);
but 'fileActionSettings' not working for me and The buttons are not displayed, please help me if I'm wrong.
Related
I'm working with FullExportMenu from Kartik. I have problem with styling confirm dialog.
My code:
$fullExport = FullExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $columns,
'exportConfig' => [
ExportMenu::FORMAT_TEXT => false,
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_EXCEL => false,
ExportMenu::FORMAT_EXCEL_X => false,
ExportMenu::FORMAT_PDF => false,
],
'filename' => 'export-faktur',
'noExportColumns' => [0, 7, 15, 16],
'hiddenColumns' => [],
'showColumnSelector' => false,
'pjax' => true,
'clearBuffers' => true,
'dropdownOptions' => [
'class' => 'btn-primary btn-sm',
'title' => Yii::t('kvexport', 'Export data in selected format'),
'icon' => '<i class="fas fa-file-download"></i>',
'itemsBefore' => [
'<div class="dropdown-header">Eksportuj całą listę</div>',
],
],
'options' => [
'id' => 'expFullInvoiceMenu',
],
'target' => ExportMenu::TARGET_SELF,
'exportContainer' => ['class' => 'btn-group-md'],
]);
I tried to use krajeeDialogSettings but it doesn't work. How do I get to the dialog styling options? I need to change the color of the dialog and add classes to the buttons. I don't want to overwrite classes in css.
I am using kartik datePicker in my site but whenever I try to use onSelect event the doesn't triggered I don't know what is the problem. I searched a lot but didn't find any solution.
This is my code:
<?php
echo DatePicker::widget([
'name' => 'check_issue_date',
'type' => DatePicker::TYPE_INLINE,
'options' => ['placeholder' => 'Select issue date ...', 'id' => 'date-picker'],
'pluginOptions' => [
'format' => 'dd-M-yyyy',
'todayHighlight' => false,
'onSelect' => 'function(dateText, inst) {
alert("hello");
}'
]
]);
?>
Look at pluginEvents on this page http://demos.krajee.com/widget-details/datepicker#settings
<?php echo DatePicker::widget([
'id'=>'scheduleProject',
'name' => 'scheduleProject',
'type' => DatePicker::TYPE_INLINE,
'language' => 'en',
'pluginOptions' => [
'format' => 'M-dd-yyyy',
'startDate' => date(\Yii::$app->params['viewDateFormat']),
'todayHighlight' => true,
'todayBtn' => true,
],
'pluginEvents' =>[
"changeDate" => "function(e) { alert(123)}",
]
]);?>
echo DatePicker::widget([
'name' => 'check_issue_date',
'type' => DatePicker::TYPE_INLINE,
'options' => ['placeholder' => 'Select issue date ...', 'id' => 'date-picker'],
'pluginOptions' => [
'format' => 'dd-M-yyyy',
'todayHighlight' => false,
'onSelect' => 'function(dateText, inst) {
alert("hello");
}'
],
'pluginEvents' => [
'onChange' => 'function(event) {
console.log(event.date);
}'
]
]);
?>
I am using kartik grid lib in yii2
This works.
[
'attribute' => 'status',
'filterType' => GridView::FILTER_SELECT2,
'filter' => ['Active' => 'Active', 'In Active' => 'In Active'],
'filterWidgetOptions' => [
'pluginOptions' => ['allowClear' => true],
],
'filterInputOptions' => ['placeholder' => 'Select'],
]
But this doesn't
[
'attribute' => 'status',
'filterType' => '\kartik\widgets\Select2',
'filter' =>['Active' => 'Active', 'In Active' => 'In Active'],
'filterWidgetOptions' => [
'pluginOptions' => ['allowClear' => true],
],
'filterInputOptions' => ['placeholder' => 'Select'],
]
Why ? I need to use the point 2 approach. But it is not working.
Changed filter type to '\kartik\select2\Select2' and it worked.
usa 'filterType' =>GridView::FILTER_SELECT2, el composer usado es use kartik\grid\GridView;
'filterType' => GridView::FILTER_SELECT2,
'filter' => ArrayHelper::map(Entidad::find()->asArray()->all(),'id', 'nombre'),
filterWidgetOptions' => [
'pluginOptions' => ['allowClear' => true],
],
'filterInputOptions' => ['placeholder' => 'Selección'],
I'm trying single-file uploads using Kartik's FileInput.
Things go fine when doing this through standard create form as the following returns non-null:
$filedata = UploadedFile::getInstance($model, 'filedata');
However it always returns null when going into Kartik's DetailView in edit mode and trying to update the file.
In view.php I have:
[
'attribute' => 'filedata',
'visible' => Yii::$app->user->can('doIt'),
'type' => DetailView::INPUT_FILEINPUT,
'rowOptions' => ['class' => 'kv-view-hidden'],
'widgetOptions' => ['options' => ['accept' => 'application/pdf'],
'pluginOptions' => [
'showUpload' => false,
'allowedFileExtensions' => ['pdf'],
'initialCaption' => $model->filename,
],
'pluginEvents' => [
'filecleared' => <whatever>,
'fileloaded' => <whatever>,
],
],
],
while in _form.php (which does work):
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?= $form->field($model, 'filedata')->widget(FileInput::classname(), [
'options' => ['accept' => 'application/pdf'],
'pluginOptions' => [
'showUpload' => false,
'allowedFileExtensions' => ['pdf'],
'initialCaption' => $model->getOldAttribute('filename'),
],
'pluginEvents' => [
'filecleared' => <whatever>,
'fileloaded' => <whatever>,
],
])
?>
Any ideas? (BTW, don't know whether 'multipart/form-data' is needed somehow in view.php as it is in _form.php, so anyone confirming this and giving some details should be welcome).
Of course, multipart/form-data is needed both in _form.php and view.php as well, as follows:
'formOptions' => ['options' => ['enctype' => 'multipart/form-data']],
'attributes' => [
...
[
'attribute' => 'filedata',
'visible' => Yii::$app->user->can('doIt'),
'type' => DetailView::INPUT_FILEINPUT,
'rowOptions' => ['class' => 'kv-view-hidden'],
'widgetOptions' => ['options' => ['accept' => 'application/pdf'],
'pluginOptions' => [
'showUpload' => false,
'allowedFileExtensions' => ['pdf'],
'initialCaption' => $model->filename,
],
'pluginEvents' => [
'filecleared' => <whatever>,
'fileloaded' => <whatever>,
],
],
],
....
]
How to add id in select2 dropdownlist kartik. The goal I want when I choose value "success" in dropdown, so value in the other dropdownlist example2 and example3 disabled is false. Before it, for dropdownlist example2 and example3 with value "yes" is false.
I've created code JavaScript but it is not working. What can I try next?
This my code :
<?php
echo $form->field($model, 'example')->widget(Select2::classname(), [
'model' => $model,
'hideSearch' => true,
'data' => ['success' => 'Success', 'fail' => "Fail"],
'language' => 'id',
'options' => [
'placeholder' => 'Pilih',
'options' => [
['id' => 'example'],
]
],
'pluginOptions' => [
'allowClear' => true,
'width' => '350px',
],
])->label('Example');
?>
<?php
echo $form->field($model, 'example2')->widget(Select2::classname(), [
'model' => $model,
'hideSearch' => true,
'data' => ['yes' => "Yes", 'no' => "No"],
'language' => 'id',
'options' => [
'placeholder' => 'Pilih',
'options' => [
'yes' => ['disabled' => true],
['id' => 'example2'],
]
],
'pluginOptions' => [
'allowClear' => true,
'width' => '350px',
],
])->label('Example 2');
?>
<?php
echo $form->field($model, 'example3')->widget(Select2::classname(), [
'model' => $model,
'hideSearch' => true,
'data' => ['yes' => "Yes", 'no' => "No"],
'language' => 'id',
'options' => [
'placeholder' => 'Pilih',
'options' => [
'yes' => ['disabled' => true],
['id' => 'example3'],
]
],
'pluginOptions' => [
'allowClear' => true,
'width' => '350px',
],
])->label('Example 3');
?>
This JavaScript code :
<?php
$this->registerJs('
$("input[type=dropdown]").change(function() {
var isi = this.value;
if(isi == "success") {
$("#example2").attr("disabled",false);
$("#example3").attr("disabled",false);
}
});
')
?>
May be this is what you want.
Add option to first select element (#example):
'pluginEvents' => [
"change" => "function() {
var value = $(this).val();
if(value == 'success')
{
$('#demo-example2').val('yes');
$('#demo-example2').trigger('change');
$('#demo-example3').val('yes');
$('#demo-example3').trigger('change');
}
}",
]