I am using Yii bootstraps datepickerRow : Check this
I want my end_date depending on start_date. i.e. end_date should be greater than start date. I've spent couple of hours on google to check whether any in-built solution available for it but didn't found any solution. Then after I written my own js code which's I think perfectly fine but its not working.
I've already achieved this thing with Cjuidatepicker and its booming.
Check my working code for yii cjuidatepicker
But I don't know why its not working for yii bootstrap datepickerRow.
Any help would be appreciated.
Following is my code:
<?php
echo $form->datepickerRow(
$identitycard, 'date_of_issue', array(
'onChange' => 'setEndDate("passport_date_of_expiry", this)',
'class' => "input-small",
'labelOptions' => array('label' => 'Date of Issue <span class="required">*</span>'),
'value' => $passportArr['date_of_issue'],
'name' => 'passport[date_of_issue]',
'readonly' => true,
'options' => array(
'autoclose' => true,
'showAnim' => 'fold',
'format' => 'yyyy-mm-dd',
'endDate' => '-infinity'
),
'prepend' => '<i class="icon icon-calendar"></i>',
'hint' => 'yyyy-mm-dd'
)
);
echo $form->datepickerRow(
$identitycard, 'date_of_expiry', array(
'class' => "input-small",
'labelOptions' => array('label' => 'Date of Expiry <span class="required">*</span>'),
'value' => $passportArr['date_of_expiry'],
'name' => 'passport[date_of_expiry]',
'readonly' => true,
'options' => array(
'autoclose' => true,
'showAnim' => 'fold',
'format' => 'yyyy-mm-dd',
),
'prepend' => '<i class="icon icon-calendar"></i>',
'hint' => 'yyyy-mm-dd'
)
);
?>
// JS code
function setEndDate(id, date) {
var selectedDate = $(date).val();
$("#" + id).datepicker({
startDate: selectedDate,
format: "yyyy-mm-dd"
});
}
In your js function setEndDate, second parameter date is not jQuery element (this in your parameter in datepickerRow). It can't be read with jQuery selector.
In your function setEndDate you can read input value as date.value; instead $(date).val();
EDIT:
setEndDate function should work with this changes (refer to plugin docs related in source code of yiibooster, for example in my yii-booster installation : protected/components/bootstrap/assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js ):
function setEndDate(id, date) {
$("#" + id).val(date.value);
$("#" + id).datepicker('setStartDate' , date.value);
}
Related
I have added datecontrol(kartik extension) in my activeForm of YII2, but it is not working.
It is shown in the activeForm, but when i click the cancel button and picker button, it has not any popup.
So I added the datecontrol and datepicker button to the out of activeForm
<?php
$form = ActiveForm::begin(
['type' => ActiveForm::TYPE_HORIZONTAL]);
echo Form::widget([
'model' => $model,
'form' => $form,
'columns' => 1,
'attributes' => [
'first_name' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Enter First Name...', 'maxlength' => 255]],
// ............................
'created' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => DateControl::classname(),'options' => [
'type' => DateControl::FORMAT_DATETIME],
'ajaxConversion'=>false,
],
]
]);?>
I tested adding datepicker to out of the activeform with this code.
echo DateTimePicker::widget([
'name' => 'dp_3',
'type' => DateTimePicker::TYPE_COMPONENT_APPEND,
'value' => '23-Feb-1982 12:35 AM',
'pluginOptions' => [
'autoclose'=>true,
'format' => 'dd-M-yyyy HH:ii P'
]
]);
But the same, is shown but not working.
I think there was many js files(maybe 2 or more) and datepicker.js file is not working because of the another one.
But didn't know how to fix that.
Can anyone help me?
I rewrited my question:
I'm using Kartick DatePicker to display a datepicker. On this datepicker, I want to disable dates using javascript. Here is what I have:
<?= DatePicker::widget([
'name' => 'mydate',
'language' => 'fr',
'clientOptions' => [
'autoclose' => true,
'format' => 'dd-M-yyyy'
]
]);?>
With the JS:
$(function(){
$("#w0").datepicker("setDatesDisabled", ['25-08-2017']);
});
I tried to change the format of the date to 2017/08/25 or 08/25/2017 but in any case nothing is displayed into the logs.
I also tried to use kvDatepicker() instead of datepicker() but this gave me
Uncaught TypeError: $(...).kvDatepicker is not a function
Any clue on what is wrong here? Thank's.
Your date is in the wrong format. It should be specified as:
$("#w0").datepicker("setDatesDisabled", ['08/25/2017']);
Of course make sure that w0 is the correct ID for the input element... it might also be that your selector doesn't match the input.
I've verified on the demo page that entering this in the browser's console correctly disables Aug 28:
$('#sandbox-container input').datepicker("setDatesDisabled", ['08/28/2017']);
If you are using Yii2 Specifically than this may help you
echo '<label id = "for-trigger">Date</label>';
echo DatePicker::widget([
'type' => DatePicker::TYPE_INPUT,
'id' => 'anyUniqueID',
'name' => 'date',
'value' => '2020-04-11',
'options' => ['placeholder' => 'Selectdate ...'],
'pluginOptions' => [
'format' => 'yyyy-M-dd',
'daysOfWeekHighlighted' => '2,3',
'todayHighlight' => true,
'datesDisabled' => ['2020-04-06', '2020-04-21']
],
'pluginEvents' => [
'changeDate' => "function(e) {
//something you want to do may be
}"
]
]);
I want to add 21 checkboxes and a text field(Name) in a good design way. Also there must be "check all button" to check all the checkboxes, how to do it in module PHP page in prestashop.
Since I am new to prestashop I don't know about the form submission, I have to save these two fields together as a json array in database.
Is that possible in prestashop? please help me regarding this.
prestashop version = 1.6
Thanks in advance
Sample code
protected function getConfigForm()
{
return array(
'form' => array(
'legend' => array(
'title' => $this->l( 'Generate Export Order Settings' ),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'checkbox',
'name' => 'display',
'values' => array(
'query' => array(
array(
'id' => 'all_fields',
'name' => $this->l('All Fields'),
'val' => '1'
),
),
'id' => 'id',
'name' => 'name'
)
),
),
'submit' => array(
'title' => $this->l( 'Save Export Settings' ),
'class' => 'button pull-right',
'name' => 'save-main-display-settings',
)
),
);
}
I don't know how to add check box in 3 columns and 7 rows and select all button to select all the checkbox.
You can use the following JS code to add check all functionality:
$('.chk_boxes').click(function(){
var chk = $(this).attr('checked')?true:false;
$('.chk_boxes1').attr('checked',chk);
});
Fiddle here: http://jsfiddle.net/HBGzy/
I'm trying to add custom tag to cakephp form input but it won't apply.
I am using Bootstrap switch
My code :
$this->Form->input('item_id', array(
'multiple' => 'checkbox',
'div' => false,
'data-label-text' => $items,
'class' => 'form-control',
));
att: i want to add item names as a 'data-label-text'
this is working (with out other attributes)
$this->Form->checkbox('aaa', array('data-label-text'=>'new item out'));
Any idea ? help ?
Try this
$options = array(0 => 'new item out 1', 1 => 'new item out 2');
echo $this->Form->input('item_id', array(
'multiple' => 'checkbox',
'div' => false,
'options' => $options,
'class' => 'form-control',
));
I'm trying to do 3 selects in cakePhp + jQuery first one with provinces, second - localities, third - schools in that place. Here is my cake code (so far):
echo $this->Form->input('proviences', array(
'type' => 'select',
'empty' => true,
'options' => $proviences,
'label' => 'Province',
'class' => 'proviences',
'before' => '<div style="float:left;width:180px"',
'after' => "</div>"
));
echo $this->Form->input('localities', array(
'type' => 'select',
'empty' => true,
'options' => $localities,
'label' => 'City',
'class' => 'localities',
'before' => '<div style="float:left;width:180px"',
'after' => "</div>"
));
$schoolList = array();
foreach($schools as $value) {
$schoolsList[]=$value['name'];
}
echo $this->Form->input('school_id', array(
'label' => 'Szkoła',
'options' => $schoolsList,
'empty' => true,
'before' => '<div style="float:left;width:240px"',
'after' => "</div>",
'onchange' => "submit();",
));
In $schools i have a list looking this way
array(
id1 => array(
'name' => 'some_name',
'province' => 'some_province',
'locality' => 'some_city'
)
)
and using this to get lists of provinces,localities and school names
I was trying to use this but couldn't get it working ;/
Filter three select boxes based on previous selections
Is there a way of doing it in jQuery without ajax?
you can do it without using ajax, but for that you would need the schools array on client side, and create/edit options based on that on the client side, too.
here is a working fiddle. (hastily thrown together, but you get the idea). You need to get the schools array into js, though. you could either use AJAX for that or, pass it as json on the page:
echo 'var schools = JSON.parse('.json_encode($schools).');
You have to think about where to place that, too, so that the variable doesn't leak into the global scope. you could put it in the jQuery closure, for example:
echo '(function($){';
echo 'var schools = JSON.parse('.json_encode($schools).');
// now the javascript from the fiddle...
echo '}(jQuery))';