In my form I use:
<%= hidden_field_tag :formtemplate, "newuser" %>
Based on this condition I want to validate in my model:
validates_format_of :email, :supervisor, :with => /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i, :message => "Adresse überprüfen.", :if => :newuser_formtemplate?
Here is newuser_formtemplate?
def newuser_formtemplate?
newuser_formtemplate = "newuser"
newuser_formtemplate == "newuser"
end
How would I have to change this to make it validate based on the hidden__field_tag?
Use attr_accessor in your model
If you are using
form_forin your view then use form object