Rails contact form alignments - css

So I have this contact form in rails
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="field">
<%= f.label :phone %><br />
<%= f.text_field :phone %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.text_area :description, :size=>"30x3" %>
</div> <br/>
<div class="actions">
<%= f.submit "Submit" %>
</div>
<% end %>
I want my form to utilize full page, i.e. I want the fields till phone to be on the left side and the description as a text area on the right horizontally.
Something like this
I am using bootstrap with the rails.
I tried with col-md-4 for 1 part and col-md-8 for another. doesn't fix that.
Please help.

From this template i made here:
http://www.bootply.com/XAMvtjjoQw
You can adapt it to ruby like this:
<form>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<%= f.text_field :name, :class => "form-control" %>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<%= f.text_field :email, :class => "form-control" %>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<%= f.text_field :phone, :class => "form-control" %>
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<label for="exampleInputFile">File input</label>
<%= f.text_area :description, :class=>"form-control", :size=>"30x3" %>
</div>
</div>
</form>

for a pure HTML layout you can do this:
<form action='' method='post'>
<div class='row'>
<div class='col-md-2'>
<div class='control-group'>
<label for="name">Name</label>
<input id="name" type='text' name='name' value='' class='form-control'>
</div>
<div class='control-group'>
<label for="email">Email</label>
<input id="email" type='text' name='email' value='' class='form-control'>
</div>
<div class='control-group'>
<label for="phone">Phone</label>
<input id="phone" type='text' name='phone' value='' class='form-control'>
</div>
</div>
<div class='col-md-10'>
<div class='control-group'>
<label for="description">Description</label>
<textarea id="description" name='description' class='form-control' rows='4'></textarea>
</div>
<div class='control-group'>
<br><input type='submit' name='submit' value='Submit' class='btn btn-sm btn-info'>
</div>
</div>
</div>
</form>

Related

How would you replace a devise form with a code snippet?

I have this signup page snippet that I want to use. My issue is I am using devise with my rails app so I'm not sure how to replace the fields in the snippet with the ruby code while retaining styles.
This is the code from devise in my view
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email, :class=>'formlabel' %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password, :class=>'formlabel' %>
<% if #minimum_password_length %>
<em>(<%= #minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, :class=>'formlabel' %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= render "teachers/shared/links" %>
and this is the snippet
<div class="container-fluid stylish-form">
<h2 class="text-center">Stylish Signup Page Using Bootstrap</h2>
<div class="row mar20">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="inner-section">
<form method="POST" action="https://google.co.in">
<div class="mar20 inside-form">
<h2 class="font_white text-center">SIGN UP</h2>
<ul>
<li class="icon-holder dsp-flex">
<i class="fa fa-facebook "></i>
</li>
<li class="icon-holder dsp-flex">
<i class="fa fa-twitter "></i>
</li>
<li class="icon-holder dsp-flex">
<i class="fa fa-instagram "></i>
</li>
</ul>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-pencil "></i></span>
<input type="text" class="form-control" name="text" placeholder="First Name...">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope "></i></span>
<input type="email" class="form-control" name="text" placeholder="Email...">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock "></i></span>
<input type="password" class="form-control" name="text" placeholder="Password...">
</div>
<div class="footer text-center">
Get Started
</div>
</div>
</form>
</div>
</div>
</div>
<h2 class="text-center font_white">Thank You For Visiting This Snippet</h2>
</div>
Simply replace your the <input> tags in your snippet. with the <%= f.email_field :email, autofocus: true %> on the original forms. Add any other missing options like placeholders and such.
Compare the resulting HTML, ultimately it will be the same.

Migration css rails login form to bootstrap

Need help migration to bootstrap.
bootstrap sound easy just go get all scss and samples to paste. But I don't know how to insert "#user, url: signup_path" into/or replace in bootstrap code to work in rails app.
html:
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(#user, url: signup_path) do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.email_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.submit "Create my account", class: "btn btn-primary" %>
<% end %>
</div>
</div>
Bootstrap code: from getbootstrap
<div class="input-group input-group-lg">
<span class="input-group-addon" id="sizing-addon1">#</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon1">
</div>
<div class="input-group">
<span class="input-group-addon" id="sizing-addon2">#</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon2">
</div>
<div class="input-group input-group-sm">
<span class="input-group-addon" id="sizing-addon3">#</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon3">
</div>
Updated:
bootstrap as follow:
<%= form_for(#user) do |f| %>
<%= render 'shared/error_messages', object: #user %>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">#</span>
<%= f.label :name %>
<%= f.text_field :name, class: 'form-control' %>
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">#</span>
<%= f.label :email %>
<%= f.email_field :email, class: 'form-control' %>
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">#</span>
<%= f.label :password %>
<%= f.password_field :password, class: 'form-control' %>
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">#</span>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, class: 'form-control' %>
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">#</span>
<%= f.submit yield(:button_text), class: "btn btn-primary" %>
</div>
<% end %>
Something like this:
<%= form_for(#user, url: signup_path) do |f| %>
<div class="input-group input-group-lg">
<span class="input-group-addon" id="sizing-addon1">#</span>
<%= f.input :name, input_html: {class: 'form-control'}, placeholder: 'Name' %>
</div>
<div class="input-group">
<span class="input-group-addon" id="sizing-addon2">#</span>
<%= f.input :email, input_html: {class: 'form-control'}, placeholder: 'Email' %>
</div>
<div class="input-group">
<span class="input-group-addon" id="sizing-addon3">#</span>
<%= f.password_field :password, input_html: {class: 'form-control'}, placeholder: 'Password' %>
</div>
<%= f.submit "Create my account", class: "btn btn-primary" %>
<% end %>
I hope you get the idea!

Css bootstrap forms (rails newbie)

I was trying to add some styling into my user_form using css bootstrap.
This is how it looks at the minute:
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(#user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.email_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Create my account", class: "btn btn-primary" %>
<% end %>
</div>
</div>
And I was trying to put it in the form of:
<form>
<div class="form-group">
<label for="name">Name</label>
<input type="name" class="form-control" id="name" placeholder="Enter name">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
<div class="form-group">
<label for="exampleInputConfirmPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputConfirmPassword1" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
My problem is that I dont know how to add the functionality to the css form. How can I do so?
Thanks in advance!
------ EDIT 1 -------
In order to clarify what is happening:
my _user_form.html.erb at the minute looks like the first set of code. However when I delete it and replace it with the second set of code nothing works.
Schema.rb
ActiveRecord::Schema.define(version: 20161210221810) do
create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "password_digest"
t.string "remember_digest"
end
end
Just add a class to the label:
<%= f.label :name, class: "my_class" %>
at the first you need to use that include your form items, and then in javascript send params to your backend! for example
<form action="demo_form.asp" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>

How to integrate Ruby with bootstrap search bar

I am trying to integrate Ruby code into the bootstrap search bar.
Here's my code thus far:
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
# Search function
<%= form_tag deals_path, :method => "get" do %>
<%= text_field_tag :search, params[:search], placeholder:"Search a deal name %>
<%= submit_tag "Search", class: "btn btn-default" %>
<%=form_tag deals_path,{:method=>'get', class:"navbar-form navbar-left", role:"search"} do%>
<div class="form-group">
<%=text_field_tag :search,"",class:"form-control",placeholder:"Search"%>
</div>
<%=submit_tag 'Seach' ,class:"btn btn-default "%>
<%end%>

Why is this Bootstrap modal stuck behind the fade?

I have a modal that is only rendered within the body tag, but it still appears stuck behind the fade.
Here is the code in my ERB:
<div class="modal fade add-video-popup" id="add-video-step-4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="titles clearfix">
<h2>Upload a Video</h2>
<p><i>Step 1 of 2 - TESTING 1, 2, 3</i></p>
</div>
<div class="content">
<% if #family_tree %>
<%= simple_form_for([#family_tree, #video], :remote => true) do |f| %>
<div class="column">
<div class="f-row">
<%= f.input :title, label: "Title:" %>
</div>
<div class="f-row">
<%= f.input :description,label: "Description:" %>
</div>
<div class="f-row">
<%= f.input :circa, as: :datepicker, start_year: Date.today.year - 5, label: "Circa:" %>
</div>
<div class="f-row">
<label for="family">Family in this video:</label>
<%= f.collection_select :user_ids, #family_tree.members.order(:first_name), :id, :first_name, {}, {multiple: true} %>
</div>
</div>
<%= f.button :submit, "Add Video", id: "video-submit" %>
<% end %>
<% end %>
</div> <!-- //content -->
</div> <!-- //modal fade -->
Here is the actual HTML generated:
<div class="modal fade add-video-popup in" id="add-video-step-4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: block;">
<div class="titles clearfix">
<h2>Upload a Video</h2>
<p><i>Step 1 of 2 - TESTING 1, 2, 3</i></p>
</div>
<div class="content">
<form accept-charset="UTF-8" action="/family_trees/1/videos" class="simple_form new_video" data-remote="true" id="new_video" method="post" novalidate="novalidate"><div style="display:none"><input name="utf8" type="hidden" value="✓"></div>
<div class="column">
<div class="f-row">
<div class="control-group string required video_title"><label class="string required control-label" for="video_title">Title:</label><div class="controls"><input class="string required" id="video_title" name="video[title]" type="text"></div></div>
</div>
<div class="f-row">
<div class="control-group string required video_description"><label class="string required control-label" for="video_description">Description:</label><div class="controls"><input class="string required" id="video_description" name="video[description]" type="text"></div></div>
</div>
<div class="f-row">
<div class="control-group datepicker optional video_circa"><label class="datepicker optional control-label" for="video_circa">Circa:</label><div class="controls"><input class="datepicker optional hasDatepicker" id="video_circa" name="video[circa]" type="text"><input class="circa-alt" id="video_circa" name="video[circa]" type="hidden"></div></div>
</div>
<div class="f-row">
<label for="family">Family in this video:</label>
<input name="video[user_ids][]" type="hidden" value=""><select id="video_user_ids" multiple="multiple" name="video[user_ids][]"><option value="3">Jackie Lynn</option>
<option value="1">Marcamus</option>
<option value="2">Mike Green</option>
<option value="8">Very</option></select>
</div>
</div>
<input class="btn" id="video-submit" name="commit" type="submit" value="Add Video">
</form> </div> <!-- //content -->
</div>
I had read on other questions that it is the positioning of the modal, so I made sure it appears right before the footer tag and not nested within any other tag and I am still having this issue.
Thoughts?

Resources