-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance to make form-control
CSS class the default and yet optional
#150
Comments
as cherry on the cake
my template (helper for gridView): /**
* Create a JS for DataPicker cancel propose events
* register this JS before use \components\helpers\ViewHelper::createdAtDatePicker()
* like this
* $this->registerJs(\components\helpers\ViewHelper::createdAtDatePickerJS(), \yii\web\View::POS_READY, 'disable-submit-filter-handler');
* @return string
*/
public static function createdAtDatePickerJS(){
return
"
reload = function(){
$(document).on('beforeFilter', null, false); //disable submit
$('.no_submit_filter').off('change.yiiGridView keydown.yiiGridView click.yiiGridView', '**'); //disable listener
window.setTimeout(function(){
$('.no_submit_filter').on('change.yiiGridView keydown.yiiGridView click.yiiGridView', function(event) {
event.stopImmediatePropagation(); //add listener to hide event for top-level listener
});
$(document).off('beforeFilter', null); //enable submit
}, 1000);
$(document).on('click', '.search-submit-circle', function(event){
$(event.target).closest('.grid-view').yiiGridView('applyFilter'); //add
});
}
reload();
$('.grid-view-date').each(function( index ) {
$(document).on('afterFilter', $(this), reload);//add event relate by id, event still work without original element
});
";
}
/**
* Create a config for dataGrid column with createdAt attribute.
* MUST use with \components\helpers\ViewHelper::createdAtDatePickerJS()
* Search model can realize two additional attributes - is a `createdAtAfter` and `createdAtBefore`
* and class into gridView
* 'options' => ['class' => 'grid-view grid-view-date'],
* @param ActiveRecord $searchModel
* @param string $widgetIdPrefix
* @return array
*/
public static function createdAtDatePicker(ActiveRecord $searchModel, string $widgetIdPrefix = '')
{
$datePickerLayout = <<< HTML
{input1}
{separator}
{input2}
<span class="input-group-addon kv-date-remove">
<i class="glyphicon glyphicon-remove"></i>
</span>
<span class="input-group-addon search-submit-circle">
<i class="glyphicon glyphicon-search"></i>
</span>
HTML;
return [
'format' => 'raw',
'label' => $searchModel->getAttributeLabel('createdAt'),
'attribute' => 'createdAt',
'filter' => \kartik\date\DatePicker::widget([
'id' => $widgetIdPrefix . 'd',
'type' => \kartik\date\DatePicker::TYPE_RANGE,
'language' => 'ru',
'name' => $searchModel->formName() . '[createdAtAfter]',
'value' => $searchModel->createdAtAfter,
'name2' => $searchModel->formName() . '[createdAtBefore]',
'value2' => $searchModel->createdAtBefore,
'layout' => $datePickerLayout,
'separator' => '<i class="glyphicon glyphicon-resize-horizontal"></i>',
'options' => ['placeholder' => Yii::t('main', 'Select date ...'), 'class' => 'no_submit_filter'],
'options2' => ['placeholder' => Yii::t('main', 'Select date ...'), 'class' => 'no_submit_filter'],
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'todayHighlight' => true,
'autoclose' => true,
]
]),
];
} |
Note (this is related to the change for #127):
Hope this clears your query on why the change is done (for developers to not be forced with |
I will take in an enhancement request for ensuring this behavior is similar for the second field input as well for DATE RANGE type. |
Ok... I have thought through this and will come up with a better enhancement to not break BC and yet achieve the above. Will post updates shortly. |
form-control
CSS class the default and yet optional
Resolved via updates to release v1.4.4. New property |
Thank you! |
Guys, BC is broken 🦀
This is way to hell! 👿
Make this options
optional, not default
Prerequisites
master
branch of yii2-widget-datepicker.Steps to reproduce the issue
Expected behavior and actual behavior
When I follow those steps, I see...
I was expecting...
Environment
Browsers
Operating System
Libraries
Updating kartik-v/yii2-widget-datepicker dev-master (9110ecc => 4a0c0fc)
Isolating the problem
class="form-control ..." still alive on demo (stable only?)
inside detailView
The text was updated successfully, but these errors were encountered: