I want a Datepicker inline with multidate enabled.
It is rendered correctly but returns only the last selected date.
Return value: '12.11.2016'
If I set 'type' to TYPE_INPUT everything is working fine.
Expected return Value: '23.11.2016, 24.11.2016, 18.11.2016, 12.11.2016'
<?= $form->field($model, 'dateString')->widget(DatePicker::className(), [
'type' => DatePicker::TYPE_INLINE,
'pluginOptions' => [
'multidate' => true,
],
]);
?>
I'm using "kartik-v/yii2-widget-datepicker": "#dev" and the model is a ActiveRecord Model.
Seems to have been fixed with this commit: https://github.com/kartik-v/yii2-widget-datepicker/commit/39e0e71277d0f115341e118a2b879a0dfcbd01c3
This will solve the problem
echo $form->field($model, 'date_time')->widget(DatePicker::classname(), [
'options' => [
'value' => "Jul-11-2020,Jul-14-2021,Jul-12-2020",
'class' => "col-md-12 form-control picker"
],
'readonly' => false,
'language' => 'en',
'type' => DatePicker::TYPE_INLINE,
'pluginOptions' => [
'format' => 'M-dd-yyyy',
'todayHighlight' => true,
'multidate' => true,
],
]);
Related
I have following widget in my yii2 application
<?= DateRangePicker::widget([
'model'=>$model,
'attribute' => 'fact_close_date_range',
'options'=>[
'placeholder'=>'Фактическая дата закрытия займа',
'class'=> 'ui input',
'id'=> 'fact_close_date_range'
],
'useWithAddon'=>false,
'convertFormat'=>true,
'presetDropdown'=>false,
'hideInput'=>false,
'pluginOptions'=>[
'opens' => 'right',
'locale'=>[
'format' => 'Y-m-d'
],
],
]);
?>
but on initial load what I am getting is input where two dates is set for today. For example 17.03.2021 - 17.03.2021, and should be my placeholder Фактическая дата закрытия займа like so. Documentation of kartik doesn't describe such things
try this :
<?= DateRangePicker::widget([
'name'=>'date_range_2',
'presetDropdown'=>true,
'convertFormat'=>true,
'value' => $model->date_range,
// 'includeMonthsFilter'=>true,
'pluginOptions'=> ['locale' => ['format' => 'Y-m-d']],
'options' => ['id'=> 'tgl-search', 'class' => 'invoice-search','placeholder' => 'Select range...']
]);
I need to load data with ajax to a Kartik Select2 but only when certain input changes values. Kind of like...
<?= $form->field($model, 'id_list')->widget(Select2::classname(), [
'data' => [],
'theme' => Select2::THEME_BOOTSTRAP,
'options' => [
'placeholder' => 'List',
],
'pluginOptions' => [
'allowClear' => true,
'action' => '#input_first'.change // or something
'ajax' => [
'url' => Url::to(['/list']),
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }')
],
],
]);?>
Have you tried to use Select2 with DepDrop plugin (http://demos.krajee.com/widget-details/depdrop)?
I'm using kartik select2 widget in Yii2 framework. Required validation rule doesn't work on it.
Here is my view code:
$form->field($model, 'city')->widget(\kartik\select2\Select2::classname(), [
'data' => $cities,
'options' => [
'class' => 'form-control',
'placeholder' => 'Please select city...',
'multiple' => false,
],
'pluginOptions' => [
'allowClear' => true
],
])->label('City');
Here is my model rule code:
[['city'], 'required'],
[['city'], 'integer']
Any idea to make the dropdown required?
Use this in plugin option
pluginOptions' => [
'initialize' => true,
],
This is working code for me
$form->field($model, 'tech_type')->widget(Select2::classname(), [
'options'=>['id'=>'tech-id'],
'data' => ArrayHelper::map(Techtypes::find()->asArray()->all(), 'tech_id', 'tech_type'),
'pluginOptions'=>[
'initialize' => true,
'placeholder' => 'Select Technician Type ...',
]
]);
I've an application that was developed using Yii2, and this application I've use Kartik Input File for upload file.
Case
From the example above, I want to remove / hide the "File" label.
And I think, that label based on model name.
This is the code I use:
<?=
$form->field($model, 'file')->widget(FileInput::classname(), [
'options' => [
'accept' => 'doc/*', 'file/*',
'enableLabel' => false,
],
'pluginOptions' => [
'allowedFileExtensions' => ['csv', 'xls', 'xlsx'],
'showUpload' => FALSE,
'showPreview' => FALSE,
]
]);
?>
How do I can remove the label above?
Thanks
For removing the label you can simply use the following:
<?=
$form->field($model, 'file')->widget(FileInput::classname(), [
'options' => [
'accept' => 'doc/*', 'file/*',
'enableLabel' => false,
],
'pluginOptions' => [
'allowedFileExtensions' => ['csv', 'xls', 'xlsx'],
'showUpload' => FALSE,
'showPreview' => FALSE,
]
])->label(false);
?>
I have a view displaying a grid view for a particular model. In my local machine, it's working well but when I deploy the application to another server, an attribute is not found hence the Unknown Property Exception. When I look at the code though, the attribute is there.
Any ideas?
Here is the model class code: http://codebin.org/view/f0a713c1
The view code:
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'is_condemned',
'label' => 'Condemned',
'class' => '\kartik\grid\BooleanColumn',
'falseLabel' => 'Active',
'trueLabel' => 'Condemned'
],
],
// set your toolbar
'toolbar' => [
['content' =>
Html::a(FA::icon('plus') . ' Add', ['/equipment/default/create'], ['class' => 'btn btn-success'])
],
'{export}',
'{toggleData}',
],
// set export properties
'export' => [
'fontAwesome' => true,
'filename' => 'equipment-export-'.time(),
'exportConfig' => [
'html' => ['showCaption' => FALSE],
'pdf' => ['showCaption' => FALSE],
],
],
'bordered' => TRUE,
'striped' => TRUE,
'condensed' => TRUE,
'responsive' => TRUE,
'hover' => TRUE,
'showPageSummary' => TRUE,
'panel' => [
'type' => GridView::TYPE_PRIMARY,
'heading' => '',
],
'persistResize' => false,
]);
The reason why it wasn't working was that the model class being imported was in lowercase. Apparently, I entered the wrong value in gii. It was just in the other servers that it was case-sensitive.
Could be either a problem with case (Uppercase, lowercase) in the namespace or in the class name or backslash path problem (/, \). In this case the class is not found and Yii shows this message.