I have two fields - end and start date(daterange) and I should pass them into controller and reload this page.
Here is my code from view:
<%= form_tag(:controller => "financial_reports", :action => 'index', :method => 'post') do%>//maybe this line should be edited
<%= datepicker_input "report","start_date", :dateFormat => "dd/mm/yy" %>
<%= datepicker_input "report", "end_date", :dateFormat => "dd/mm/yy"%>
<%end%>
and generated HTML() :
<form accept-charset="UTF-8" action="/financial_reports?method=post" method="post"...>
<input id="report_start_date" name="report[start_date]" size="30" type="text" class="hasDatepicker"><script type="text/javascript">
<input id="report_end_date" name="report[end_date]" size="30" type="text" class="hasDatepicker"
<input class="btn wide" id="btn-report" name="commit" type="submit" value="Run Report">
</form>
Can I get datepicker value like this :
$('#datepicker').datepicker({
onSelect: function(dateText, inst) {
$("input[name='report[start_date]']").val(dateText);
}
});
and I need to pass them into controller and reload this page, because in this page controller.
HERE I NEED TO PASS JQUERY VALUE
@financial_reports = current_user.financial_reports.where(:created_at => start_date.to_date..end_date.to_date)
or I should add another action or method ? What you can suggest ?