I'm trying to implement the FriendsOfCake\Search
plugin in a CakePHP. I'm not 100% sure that I've implemented the search type correctly, but when I submit my form to try and use a date to search I'm receiving the following Fatal Error:
Error: Call to a member function format() on a non-object
I'm assuming somewhere along the way my date isn't being formatted as a date object, but not sure where I'm needing to do that at, if at all. Here are the code snippets I'm working with.
UsersTable.php - Inside of my searchConfiguration()
method
->compare('created_start', [
'field' => $this->aliasField('created')
])
index.ctp - Generation of my form
<?= $this->Form->label('created_start') ?>
<?= $this->Form->date('created_start') ?>
I think that's all, I have text boxes and select boxes working as a part of the form, it's just the date that I haven't been able to get up and running.
Here is the Stack Trace for the error message (I believe this is what was being asked for, it's the left hand column of my page.
Cake\Error\BaseErrorHandler->handleFatalError
Core/src/Error/BaseErrorHandler.php, line 90
Cake\Error\BaseErrorHandler->Cake\Error\{closure}
[internal function]
The full Error block says:
Error: Call to a member function format() on a non-object
File /var/www/<project_name>/vendor/cakephp/cakephp/src/Database/Type/DateTimeType.php
Line: 94
Line 94 of the DataTimeType.php is a part of the toDatabase() method. It is attempting to convert a datetime object into a string to use with the database. Specifically line 94
return $value->format($this->_format);
Using Cake version 3.1.0