Search code examples
htmlcssruby-on-railssimple-form

Trying to pull html tag into my Rails simple-form to pull id tags css attributes


Quick one. I have the html code below. I'm trying to refactor this into simple form code for use in my rails app.

<input type="email" class="form-control" id="newsletter" placeholder="Please Enter Your Email">

This is what i've got so far but it's not really pulling in the Id value to look how I want it to.

<%= f.input :email, placeholder: "Please Enter Your Email", class: "form-control", id: "newsletter", :input_html => { :type => "email" }, label: false  %>

Solution

  • Ok so it was this simple that I just about answered it myself after filling in the question. So I'll just answer it now. To pull in the id tag for Rails simple-form code You need the below syntax.

    <%= f.input :email, placeholder: "Please Enter Your Email", class: "form-control", :input_html => { id: "newsletter", type: "email" }, label: false  %>
    

    So the :input_html => { id: "newsletter"} brings in the html id tag.

    Easy I know. I've left this here though for people in need if they come across something similar.