Remove tooltip from kartik/date/datepicker - datepicker

I use kartik DatePicker in my activeform.
use kartik\date\DatePicker;
My activeform field:
<?= $form->field($model, 'transferred_date')->widget(DatePicker::className(), [
'value' => date('d-M-Y', strtotime('+2 days')),
'options' => ['placeholder' => 'Select date ...'],
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'todayHighlight' => true
]
])->label('Transferred Date');
?>
When I hover the mouse on calendar icon, it shows a tool tip like this.
I have to remove the tooltip. How can I?

When reading the doc you can read this in the settings:
pickerButton: mixed the calendar picker button configuration - applicable only when type is set to DatePicker::TYPE_COMPONENT_PREPEND or DatePicker::TYPE_COMPONENT_APPEND. This can be one of the following types:
string, if this is a string, it will be displayed as is (and will not be HTML encoded).
boolean, if this is set to false, it will not be displayed.
array, this is the default behavior. If passed as an array, it will be considered as HTML attributes for the picker button addon. The following special keys are recognized:
icon, string the bootstrap glyphicon name/suffix. Defaults to 'calendar'.
title, string|boolean the title to be displayed on hover. Defaults to 'Select date & time'. If this is set to false, it will not be displayed.
So i can say without testing that it should be something like this:
<?= $form->field($model, 'transferred_date')
->widget(DatePicker::className(), [
'type' => DatePicker::TYPE_COMPONENT_PREPEND,
'pickerButton' => ['title' => false],
'value' => date('d-M-Y', strtotime('+2 days')),
'options' => ['placeholder' => 'Select date ...'],
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'todayHighlight' => true
]
])->label('Transferred Date');
?>
So you missed this in the config:
'type' => DatePicker::TYPE_COMPONENT_PREPEND,
'pickerButton' => ['title' => false],

Related

How to highlight a date(Some other date not the today's date) in Kartik Datepicker

I'm able to highlight current date with 'todayHighlight' => true, but I want to highlight some other date.
You can use this function beforeShowDay as pluginOptions array key.
Here is simple example:
<?= $form->field($model, 'myDate', ['showLabels' => false])->widget(DatePicker::className(), [
'size' => 'sm',
'type' => DatePicker::TYPE_INPUT,
'pluginOptions' => [
'autoclose' => true,
'format' => 'Y-m-d',
'startDate' => date('Y-m-d'),
'endDate' => date('Y-m-d', strtotime('-1 day')),
'weekStart' => 1,
'beforeShowDay' => new \yii\web\JsExpression("function (dates) {
console.log(dates); // List with available dates as date object defined with startDate/endDate (for mor customisations if needed)
return {classes: 'highlight', tooltip: 'Pick this day'};
}
}"),
]
]); ?>
Don't forget to define class (.highlight in this case) in your css.
.highlight{background: #ebf4f8}

Create a SelectBox using Form Helper in CakePHP3

I am trying to make a combo box for an edit page.
echo $this->Form->select('status',
['empty' => 'Select Status'],
['class' => 'form-control', 'required']
);
Here I want to add 2 things :
$options = array('0' => 'Inactive',
'1' => 'Active',
);
and selected value. suppose that is $status;
I tried with different options but sometime it do not add classes and sometime it shows options in tag
It will be great if somebody give clue.
Thanks
<?= $this->Form->input('status', [
'type' => 'select',
'options' => ['0' => __('Inactive') , '1' => __('Active')],
'empty' => __('Select Status'),
'class' => 'form-control',
'required' => true, 'label' => __('Type')
])
?>

how to disable breadcrumb for some controllers yii2?

I want disable or change breadcrumb in Yii2 application. How to do that.I
tried to change with
echo Breadcrumbs::widget([
'itemTemplate' => "<li><i>{link}</i></li>\n", // template for all links
'links' => [
[
'label' => 'Post Category',
'url' => ['post-category/view', 'id' => 10],
'template' => "<li><b>{link}</b></li>\n", // template for this link only
],
['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]],
'Edit',
],
]);
Well, first of all change it back to default, which is:
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
According to yii2 documentation if you set the value for $links to an empty array, breadcrumbs will not show up.
How do you do it?
Check above code , the $links value in being set by $this->params['breadcrumbs'] variable, which is available in every view file. So in your view file just do this:
// empty if you don't want breadcrumbs
$this->params['breadcrumbs'] = [];
Otherwise set some value and your breadcrumbs will show up.

Spanish location for yii2-date-picker-widget

I am working on the basic template of Yii2. I use the 2amigos yii2-date-picker-widget.
Datepicker is working fine, but it keeps showing me the default language (that is English) instead of Spanish.
As you can see in the code below, the language param is set to 'es':
<?= $form->field($model, 'alta')->widget(
DatePicker::className(), [
'inline' => false,
'clientOptions' => [
'format' => 'yyyy-mm-dd',
'weekStart' => 1,
'todayBtn' => 'linked',
'clearBtn' => true,
'language' => 'es',
'autoclose' => true,
'todayHighlight' => true
]
]);?>
It seems tha the 2amigos Datepicker comes into the proper location whith:
DatePickerLanguageAsset::register($view)->js[] = 'bootstrap-datepicker.' . $this->language . '.min.js';
that means #vendor/bower/bootstrap-datepicker/dist/locales/bootstrap-datepicker.es.min.js, that is an existing file containing my desired spanish location:
!function(a){a.fn.datepicker.dates.es={days:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado","Domingo"],daysShort:["Dom","Lun","Mar","Mié","Jue","Vie","Sáb","Dom"],daysMin:["Do","Lu","Ma","Mi","Ju","Vi","Sa","Do"],months:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],monthsShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],today:"Hoy",clear:"Borrar",weekStart:1,format:"dd/mm/yyyy"}}(jQuery);
Why this translation is not being applied?
A lot of thanks.
Your translation doesn't work because of wrong syntax, You should move Your language param from 'clientOptions' to top level array:
<?= $form->field($model, 'alta')->widget(
DatePicker::className(), [
'inline' => false,
'language' => 'es',
'clientOptions' => [
'format' => 'yyyy-mm-dd',
'weekStart' => 1,
'todayBtn' => 'linked',
'clearBtn' => true,
'autoclose' => true,
'todayHighlight' => true
]
]);?>

How to set place holder copy in date select menu in CakePHP

I am using CakePHP 1.3 to create a select menu for date of birth (as below). I can set the default starting values as either blank or a selected date, but ideally I would like to have DD-MM-YYYY as the starting displayed values:
echo $form->input('dob',
array(
'before' => '',
'between' => '',
'after' => '',
'label' => false,
'divider' => false,
'monthNames' => false,
'selected' => false,
'empty' => true,
'dateFormat' => 'DMY',
'minYear' => date('Y') - 70,
'maxYear' => date('Y') - 16,
'error' => array('wrap' => 'div', 'class' => 'error-copy')
));
What I get:
What I would like:
Thank you
I believe if you want to do this you will have to make your own date fields and not use the FormHelper since you can only set a default date to it, what you want involves adding an element to the fields.
You could also try JQuery's datepicker out, it's what I use in my project, and since it's a text field you can just set whatever you want as a placeholder.
http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-select-checkbox-and-radio-inputs
echo $this->Form->dateTime('Contact.date', 'DMY', '12',
array(
'empty' => array(
'day' => 'DAY', 'month' => 'MONTH', 'year' => 'YEAR',
'hour' => 'HOUR', 'minute' => 'MINUTE', 'meridian' => false
)
)
);
I believe you can only set a default date on the date fields.
echo $this->Form->input('close_time', array('type' => 'time', 'selected' => '13:30:00'));
Cookbook entry
For the benefit of anyone Googling to find the answer to this question 1+ years after it was asked, we can now simply do the following to set default placeholder (temporary) values in CakePHP forms that are easily replaced when clicked:
<?php echo $this->Form->input('Email', array(
'placeholder'=>'Enter Your Email Here'
)); ?>
I like to include 'label' => false as well to make the forms really minimalist.