Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value for date_helper in formtastic

As basic as it sounds, I can't make the date_helper default to a date, as in:

- semantic_form_for resource do |f|
  - f.inputs do
    = f.input :issued_on, :default => Date.today
  = f.buttons

The above just renders blank columns if resource does not have a date.

Would appreciate any pointer on what I'm possibly doing wrong.

like image 550
Hakan Ensari Avatar asked Dec 23 '22 07:12

Hakan Ensari


1 Answers

You can set the default on the object itself on your controller

def edit
  @resource = Resource.find(params[:id])
  @resource.issued_on ||= Date.today
end
like image 182
hgmnz Avatar answered Jan 09 '23 12:01

hgmnz