Updating calendar date from another button

#1

I’m using Agile UI to allow the user to set a date range for a database query, so create a form with two fields, $startDate and $endDate. I also want to give the user a few buttons that allow the user to push a button a set those two fields to the appropriate date for the button (such as “Last Week”, “YTD”, etc.).

I have it working just fine, using the snippet

$b->js('click', $startDate->jsInput()->val($dates['start']->format('M d, Y')));
$b->js('click', $endDate->jsInput()->val($dates['end']->format('M d, Y')));

$b is my button and $dates is the array that has the dates to which $b should set the end points fields.

If the user clicks a button to change the date range, the date range appears to be changed – and it is, as the query will use the correct dates. However, if the user clicks on the date field to manually change the button the the popup window will appear and the date that it starts out is whatever date that was the default when the page was loaded, not the date that was set by the last button press.

I think what I need to do is have another jsExpression bound using $b->js(‘click’) to set the focusDate for the Semantec UI component, but I can’t figure out how do to that using Agile UI.

Can anyone help me out? It seems like this should be pretty simple, but it’s escaping me.

Thanks in advance.