Add a static text in a middle of my form #794

Closed
sebfie opened this Issue Feb 8, 2012 · 8 comments

Comments

Projects
None yet
3 participants

sebfie commented Feb 8, 2012

Hello,

I want to write some text in the middle of my form, how can i do that? My form looks like :

form :html => { :enctype => "multipart/form-data" } do |f|
  f.inputs "Details" do
    f.input :civility
    f.input :society
    f.input :last_name
    f.input :address
    f.input :postal_code
    f.input :country, :as => :string
    f.input :email
    f.input :reduction_code
    f.input :message
    f.input :total
    f.input :city
  end
  f.buttons
end

eswat2 commented Feb 10, 2012

you can try this;

form :html => { :enctype => "multipart/form-data" } do |f|
  f.inputs "Details" do
    f.input :civility
    f.input :society
    f.input :last_name
    f.input :address
    f.input :postal_code
    "<li>Hello</li>".html_safe <<
    f.input :country, :as => :string
    f.input :email
    f.input :reduction_code
    f.input :message
    f.input :total
    f.input :city
  end
  f.buttons
end

i used this same mechanism to add a floating div menu mechanism to a custom edit form we needed...

Owner

justinfrench commented Feb 10, 2012

@eswat2 nice!

Owner

justinfrench commented Feb 10, 2012

Closing this as a duplicate of #795

eswat2 commented Feb 10, 2012

Ditchou,

let me know if you have any questions about this, just email me...

** the menu thing i was talking about had a floating div holding a table with checkbox inputs in the rows (each row was built on the fly from a set of keys contained in the object being edited). Used this to provide a "check/uncheck all" mechanism for properties setup to use input=checkbox.

eswat2 commented Feb 10, 2012

forgot to mention that this was done for an ActiveAdmin project...

eswat2 commented Feb 14, 2012

actually, this little trick only appears to work if you inject the html into the top of the form. You get all sorts of nasty errors trying to do in between two f.input's. After a messing with this a bit more, we decided to remove the "extra" html from the form definition completely and instead we're now injecting the extra elements using jQuery (ie. prepend). In our case, we're creating a div that floats to the right side of the screen (across from each of the f.input labels).

Sorry if i confused you with my post...

** again, email me if you have any questions and i'll try to explain what we're doing in more detail.

sebfie commented Feb 16, 2012

I send you an email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment