Reputation: 3528
I have old HTML code with html and css..
<form action="login" method="post">
<div class="field">
<label for="username">Username</label>
<input type="text" class="text" id="username" name="username" value="just click login !"/>
</div>
<span class="fright">
<button class="button" type="submit"><strong>Log In</strong></button>
</span>
</div>
How can i convert this code to decent rails code? I came up with this, but it ain't right :-( :
<% form_for :user, @user, :url => { :action => "login" } do |f| %>
<% div_for f, :class => "field text" do %>
<%= f.text_field :username %>
<%= f.password_field :password, :class => "field text" %>
<% end %>
<span class="fright">
<%= submit_tag '<strong>Inloggen</strong>', :class => "button",:disable_with => 'verwerken...' %></span>
<% end %>
I'm having problems with the
<strong>Inloggen</strong>
And with the
<% div_for f, :class => "field text" do %>
Upvotes: 0
Views: 408
Reputation: 187272
submit_tag
generates the text as the value attribute of the input
tag.
submit_tag "Edit this article"
# => <input name="commit" type="submit" value="Edit this article" />
So adding strong
to that text is not gonna work, and it generates a <input>
and it appears you want a <button>
. So just use html here as well.
<button class="button" type="submit"><strong>Log In</strong></button>
Since you dont need to alter this based on any variables, you don't need to render it with ruby.
And you don't need div_for
based on your target HTML. Simply use . No reason to make your template render that with ruby.
Lesson here is don't try too hard. Sometimes plain HTML is fine.
Upvotes: 1
Reputation: 14977
Try something like this:
<% form_for :user, @user, :url => { :action => "login" } do |f| %>
<div class="field">
<%= f.text_field :username %>
<%= f.password_field :password, :class => "field text" %>
</div>
<span class="fright">
<%= submit_tag 'Inloggen', :class => "button strong",:disable_with => 'verwerken...' %>
</span>
<% end %>
I moved <strong>
from submit_tag description to class, because I'm not sure if submit tag will accept it. So you need to define .strong class in your css.
Upvotes: 1