Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:12:17+00:00 2026-06-02T04:12:17+00:00

I am able to render a form in HAML but I am not sure

  • 0

I am able to render a form in HAML but I am not sure how to validate it.

Here is what I have so far:

  #disclosure-form-container
    = form_for([:mobile,@disclosure], :html => {:id => "disclosure-form", :remote => true}) do |f|
      %p
        =f.label :display_as, (t :select_disclosure_type)
        =f.select :display_as, options_from_collection_for_select(Disclosure.basics, :display_as, :name, f.object.display_as)
      %p
        =f.label :notes, (t :notes)
        =f.text_area :notes, :class => "#{validation_rules(:free_disclosure_notes)}", :rows => 5 , :id => "disclosure_notes_entry"
        = buttonset({:submit_label => (t "buttons.influencers.disclosures.create"),:submit_css_class => "call-to-action",:cancel_url => "#",:direction => :left_to_right})

This renders a form with two fields and a button to click submit. But what if people just enter submit without doing much? Where do I put the validation code and how do I validate this form?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:12:20+00:00Added an answer on June 2, 2026 at 4:12 am

    A user enters data that should be saved in your model and then stored in your DB. So it’s naturally to implement validation on model-level. Rails allows you to create validation for models easy. Here you can read about it. In a few words: adding few lines to your model prevent it to be saved with inconsistent data.

    But you can in addition to model-level validation use client-side validation: i.e., data will be checked before sending to server. This way user don’t have to submit form to find out that he forgot to fill some required field. But of course this can’t be any guaranty as it’s easy to bypass. Here more about client-side validation.

    So, as you see, Haml can’t help you with validations. It’s a great tool, but not for this purpose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My issue is not able to render the chart in .tpl file. The following
Application able to record error in OnError, but we are not able to do
I have a scenerio where I want to dynamically render a custom form object.
I know this has been asked in various ways, but I have not been
I was able to successfully render my first django form inside an extjs tab.
I'm trying to generate a form using the form_for helper in RoR but I
Issue: not able to close modal dialog I have the following code, it works
I have custom Question objects which I render into html form elements. I want
I am not able to use the SSRS report viewer in a web form
On form submission, it's telling me that it was successfully created but it's not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.