Closed zofe closed 10 years ago
done.. (both)
I use $filter->add('person.dob','Geburtsdatum', 'date')->format('d.m.Y', 'de'); But no mathes because the date ist not beeing convertet back to Y-m-d before qerying the database. I'm I doing something wrong?
this is not related with this issue, however accepted format for date field are related to the used datepicker
https://github.com/zofe/rapyd-laravel/blob/master/src/DataForm/Field/Date.php#L72
http://bootstrap-datepicker.readthedocs.org/en/release/options.html#format
and "dots" can cause problems in QS I think.. however can you try to find the problem?
I've also tried to add a date field in DataFilter and I've noticed that there is not an automatic conversion to Y-m-d to compare the value with DB, in contrast to daterange, where it exists. I think that date fields need a getValue function like datarange fields (https://github.com/zofe/rapyd-laravel/blob/master/src/DataForm/Field/Daterange.php#L15) to make this conversion. What do you think about this?
as said in thread to transform a date from "input" to the standard iso datestamp the Date field must know your input format. So you must use format() and be also sure that your format notation is supported by javascript datepicker: https://github.com/zofe/rapyd-laravel/blob/master/src/DataForm/Field/Date.php#L72 http://bootstrap-datepicker.readthedocs.org/en/release/options.html#format
and documented in the wiki, see date field: https://github.com/zofe/rapyd-laravel/wiki/Field-list
@farynato if you're sure that you're working right and DataFilter does not support Date field open a new issue and be propositive about how to solve the problem. (pull request, or suggestions are welcome)
Sorry for not specify, but I'm using: $filter->add('fecha_nacimiento','DOB','date')->format('d/m/Y', 'es')
I think that the format is supported, however, the query executed is:
select * from ratones
where fecha_nacimiento
LIKE '%05/05/2015%'
If I change the field to datarange, it works, so it's for this for I was saying about a getValue function in Date.php, like in Datarange.php
so please open a new issue, I hope to fix asap
@zofe Ok, I will open a new issue I'll try to be propositive, but it's still a little difficult for me because I am a beginner in laravel. Thank you very much.
DataFilter is good enough as is, but in some cases a closure on fields or main class can help to build better/complex filters. Another idea is to bind datafilter with eloquent query-scopes.
Some Ideas:
Or eloquent query scope binding:
Note that $value, it's not just Input::get('search'); It is $filter->field('search')->getValue(); So for complex or multiple fields (like autocomplete, date, tags..) it's a pre-processed value. For example for a Date field that use a custom format $value is instead a iso datestamp Y-m-d, so ready to be used in queries.