I'm trying to figure out how to set a default value to a qeury result with setDefault() for a Date field in a form object. Because I want to set the date to the latest user bookdate. Do I need to add a query to the model or can it be done inside the form object?
$bookdate = new Date(
"book_date",
[
"class" => "form-control",
//"value" => date('Y-m-d')
]
);
$bookdate->setLabel("Date");
$bookdate->setDefault('2020-01-01'); /* here */
$this->add($bookdate);
// the query would be like this with user_id being variable
// SELECT MAX(book_date) FROM urenboeker.time_registration WHERE user_id = 1;