Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails3 hidden_field in haml

I use rails and haml, haml-rails.

How I create hidden_field in haml?

I have field:

.field
= f.label :submit_date
= f.datetime_select :submit_date

I will hide this field. User not able to modify datetime manualy. I will store in db datetime when object was created. I have absolutely no idea how to do it. I know how to do it in erb, but i will use haml.

like image 324
esio Avatar asked Apr 30 '12 16:04

esio


2 Answers

If you want to create a hidden field with say the customer_id, you'd:

= f.hidden_field :customer_id, value: @customer.id

Note: you mention that you want to store a created_at when the object is created. If you have "timestamps" on your model, or "created_at" and "updated_at" columns, rails will take care of this for you (and is the recommended/standard practice)

like image 108
Jesse Wolgamott Avatar answered Oct 08 '22 21:10

Jesse Wolgamott


I think this is rails FormHelper method. If you want to do it in HAML, you can use something like this:

%input{:type=>"hidden", :value=>params[:order], :name=>:order}
like image 38
dmaixner Avatar answered Oct 08 '22 20:10

dmaixner