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 6655719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:33:17+00:00 2026-05-26T01:33:17+00:00

so there I have this code in rails <%= f.label :year, Year: %><br />

  • 0

so there I have this code in rails

<%= f.label :year, "Year:" %><br />
<%= f.text_field :year %></p>

that returns in html a code like this one

< input id="car_year" name="car[year]" size="30" type="text" class="hasDatepicker"><br />

see the class=”hasDatepicker”? I use the jquery to get the calendar to select dates
this one is working good

but here is another one (using meta_search https://github.com/ernie/meta_search)

<td>
<%= f.label :year_gte, "Years from" %><br />
<%= f.text_field :year_gte, :size  => 8 %></td>

that outputs an html code like this one

< input id="search_year_gte" name="search[year_gte]" size="8" type="text"><br />

obvius this one is missing the class=”hasDatepicker” that needs the jquery to display the calendar

The question is: How do I get the class thing to display in that field
Thanks all for your time.

Update 2
I just found the problem I need an javascript code in my view for search_year_gte as I have one for car_year
looks like

<script>
    $(function() {
        $( "#search_year_gte" ).datepicker({
      dateFormat: 'yy-mm-dd',
      yearRange: '1980:2012',
            changeMonth: true,
            changeYear: true
        });
    });
</script>

<script>
    $(function() {
        $( "#search_year_lte" ).datepicker({
      dateFormat: 'yy-mm-dd',<br />
      yearRange: '1980:2012',<br />
            changeMonth: true,
            changeYear: true
        });
    });
</script>

but can I just use one script for both values?
for search_year_lte and search_year_gte

  • 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-05-26T01:33:18+00:00Added an answer on May 26, 2026 at 1:33 am

    Did you try adding the class as an attribute?

    <%= f.text_field :year_gte, :size => 8, :class => "hasDatepicker" %>
    

    Have a look at the documentation if you want to know what attributes you can pass to the text_field helper.

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

Sidebar

Related Questions

I have this legacy code that I am working with and there is code
I have trouble finding way to correctly refactor this code so that there would
I have code which needs to do something like this There is a list
I have this code: = link_to unsubscribe instantly, *|UNSUB|*.html_safe That generates this HTML: <a
I have this code so far which perfectly but relies on there being a
Is there a better way to do this jquery code? Currently I have to
There is probably is simple fix for this but I currently have code similar
I have the following piece of code from a book. There is this function
I have this code in my controller for a Rails app: def delete object
I'm trying to create a Rails app template I have this block of code

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.