I have try use Filter Scopes default value for type: date, not working, but for type:text, it’s working.
example config_filter.yaml:
scopes:
InspDate:
label: Inspection Date
type: date
default: '2023-02-28" or Carbon::now()
conditions:
equals: true
between: Inspdate >= ':after' AND InspDate <= ':before'
Inspector:
label: Inspector Name
default: 'Peter Pan'
type: text
conditions: Inspector = :value
…
Even using function listFilterExtendScopes(%filter), still not working
public function listFilterExtendScopes($filter)
{
$filter->addScopes([
'InspDate' => [
'label' => 'Inspection Date',
'type' => 'date',
'default' => '2023-02-28',
],
]);
}
The type: date, I think it’s using \modiles\backend\filterwidgets\Date.php
Any one has solution?
Thanks!
daft
March 1, 2023, 1:56am
#2
Take a look at the Test plugin for working examples:
The Users page has a Created filter that is an implementation of type: date
.
Hello
I think tommyctwu is right.
There is a bug in the date widget.
Take a look at an example (photo):
1 choose a date
2. there are no records, but there should be
3 look at the last query to the database (I choose date and the query is with the same time) The query range must be empty!!
config_filter.yaml:
===================================
Filter Scope Definitions
===================================
scopes:
id:
label: ‘#id ’
type: text
modelScope: modelFind
conditions:
equals: id = :value
username:
label: Email
type: text
modelScope: userFilter
conditions:
equals: user = :value
contains: user like '%:value%'
platne:
label: 'Płatne & Darmowe'
type: switch
conditions:
- 'total>0'
- 'total=0'
status:
label: 'Opłacone'
type: dropdown
emptyOption: 'Status Płatności'
options:
paid: 'Opłacone'
await_pay: 'W trakcie'
cancelled: 'Nie opłacone'
paid_at:
label: 'Złożone pomiędzy:'
type: date
showWeekNumber: true
conditions:
between: paid_at >= ':after' AND paid_at <= ':before'
daft
April 5, 2023, 11:04am
#5
Can you reproduce it using the test plugin above? Using this plugin as a reference, what are the conditions to produce the bug…
However, I was wrong. I had the wrong time zone set, which confused me (+ two hours).
I thought a time range from same day to same day, the query would return the whole day - that’s my mistake.
The widget works correctly.
Thank you .
1 Like