Rails - how to integrate a form with bootstraps css

0 votes

I'd want to use Bootstrap to update the appearance of my forms.

Here's how my form's current view looks (it's quite basic...)

<div class="field">
    <%= form.label :first_name %>
    <%= form.text_field :first_name %>
  </div>

  <div class="field">
    <%= form.label :last_name %>
    <%= form.text_field :last_name %>
  </div>

  <div class="field">
    <%= form.label :age %>
    <%= form.number_field :age %>
  </div>

  <div class="field">
    <%= form.label :email %>
    <%= form.text_field :email %>
  </div>

  <div class="actions">
    <%= form.submit %>
  </div> 

<form>
  <div class="mb-3">
    <label for="exampleInputEmail1" class="form-label">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
    <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
  </div>
  <div class="mb-3">
    <label for="exampleInputPassword1" class="form-label">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1">
  </div>
  
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

I'm not sure how to combine the ruby code and the HTML.

Jun 9 in CSS by Edureka
• 9,800 points
15 views

1 answer to this question.

0 votes

Here is how I did it  in my case . . .

<h1 class="display-6">Add a new Barber below</h1>
  <div class="mb-3">
  <div class="form-control">
    <label  class="form-label"><%= form.label :first_name %></label>
    <%= form.text_field :first_name %>
  </div>
  </div>

  <div class="mb-3">
  <div class="form-control">
    <%= form.label :last_name %>
    <%= form.text_field :last_name %>
  </div>
  </div>

  <div class="mb-3">
  <div class="form-control">
    <%= form.label :age %>
    <%= form.number_field :age %>
  </div>
  </div>

  <div class="mb-3">
  <div class="form-control">
    <%= form.label :email %>
    <%= form.text_field :email %>
  </div>
  </div>
<!--Submit button below for the above form-->
  <button type="button" class="btn btn-outline-success"><%= form.submit'Create a new barber?' %> </button>
answered Jun 28 by Edureka
• 9,540 points

Related Questions In CSS

0 votes
1 answer
0 votes
1 answer

What is the proper way to display a logo with CSS?

An <img> element is the proper way ...READ MORE

answered Jun 10 in CSS by Edureka
• 9,540 points
28 views
0 votes
1 answer

How to create material design input form using css and bootstrap?

Try with this code. HTML: <div class="main_div"> ...READ MORE

answered Jun 21 in CSS by Edureka
• 9,540 points
100 views
0 votes
1 answer
0 votes
1 answer

How to style a checkbox using CSS?

Add focus outline input[type="checkbox"]:focus + span:before { ...READ MORE

answered Jun 21 in CSS by Edureka
• 9,540 points
18 views
0 votes
1 answer

How to convert a web page(html,css,js) into android app?

I used Phonegap a lot for this, ...READ MORE

answered Jun 28 in CSS by Edureka
• 9,540 points
37 views
0 votes
1 answer

How to overlay image with color in CSS?

Use the rgba() Function to Overlay Background ...READ MORE

answered Jun 28 in CSS by Edureka
• 9,540 points
21 views
0 votes
0 answers

Using Flex CSS and Bootstrap for a responsive layout

I've been playing with fully responsive layouts ...READ MORE

Jun 30 in CSS by Edureka
• 9,800 points
10 views
0 votes
1 answer

How to build a special polygon (a kite shape) with HTML & CSS only?

I made two divs, one for Arc ...READ MORE

answered May 28 in CSS by Edureka
• 9,540 points
70 views
0 votes
1 answer

Is there any way to colorize a white PNG image with CSS only?

Filters can be used with -webkit-filter and ...READ MORE

answered May 27 in CSS by Edureka
• 9,540 points
66 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP