I have a form_for form to which I added custom fields using *_tag methods.
For normal form_for elements I have validation inside the model, however I am not sure what should I do with my text_field_tag elements.
What would be the most elegant way to validate those fields?
Code update:
<%= form_for(@member, :html => {:class => "generic-form"}) do |f| %>
<% if @member.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@member.errors.count, "error") %> prohibited this member from being saved:</h2>
<ul>
<% @member.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.label :username, "Username:" %>
<%= f.text_field :username %>
<%= f.label :password, "Password:" %>
<%= f.password_field :password %>
<%= label_tag "repeatPassword", "Repeat password:" %>
<%= password_field_tag "repeatPassword" %>
<%= f.label :email, "Email:" %>
<%= f.text_field :email %>
<button type="submit" name="commit">Register</button>
<% end %>
I guess you have an action which update/create a Member instance. In this action you could do something like this:
Hope this Helps!