Skip to content

Instantly share code, notes, and snippets.

@wdog
Created April 10, 2017 08:15
Show Gist options
  • Save wdog/3d0d9661bd213e8ccdfdfa15c76a086b to your computer and use it in GitHub Desktop.
Save wdog/3d0d9661bd213e8ccdfdfa15c76a086b to your computer and use it in GitHub Desktop.
(new THead)
->setComponents([
(new FiltersRow)
->addComponents([
(new Filter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_EQ)))
->setName('d_doc')
->setTemplate('*.components.filters.datetime_picker')
->setRenderSection('filters_row_column_d_doc')
->setFilteringFunc(function ($val, EloquentDataProvider $provider) {
$date = Carbon::createFromFormat('d/m/Y', $val)->toDateString();
$provider->getBuilder()->where('d_doc', '=', $date);
}),
]),
...
<?php
/** @var Nayjest\Grids\Components\Filter $component */
$id = uniqid();
?>
<?php if ($component->getLabel()): ?>
<span><?= $component->getLabel() ?></span>
<?php endif ?>
<input
class="form-control input-sm"
style="display: inline; width: 85px; margin-right: 10px"
name="<?= $component->getInputName() ?>"
type="text"
value="<?= $component->getValue() ?>"
id="<?= $id ?>"
>
<script>
$(function () {
// DATES
// https://github.com/xdan/datetimepicker
jQuery.datetimepicker.setLocale('it');
var opts = {
timepicker: false,
format: 'd/m/Y',
}
$('#<?= $id ?>').datetimepicker(opts);
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment