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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:22:11+00:00 2026-06-11T11:22:11+00:00

UPDATE: So, I’ve found this , and apparently that’s why this old way of

  • 0

UPDATE: So, I’ve found this, and apparently that’s why this old way of doing things isn’t working, ActiveAdmin must use Formtastic 2.x. As directed, I’ve now created a file in app/inputs/date_picker_input.rb that looks like this:

class DatePickerInput
  include Formtastic::Inputs::Base

  def to_html
    puts "this is my datepickerinput"
  end
end

And my controller now looks like this:

  f.input :open_date, :as => :date_picker
  f.input :close_date, :as => :date_picker

But now I’m running into this error:

ActionView::Template::Error (undefined method 'html_safe' for nil:NilClass):
1: render renderer_for(:edit)

Any thoughts?

I’ve ran into a problem with Formtastic automatically formatting dates into a format I’m not wanting (Y-m-d h:i:s Z) when I try to render :as => string so I can use a datepicker on the field. In trying to solve this, I came across this solution.

It seems to make sense and is the exact same problem I am dealing with. However, I don’t seem to be able to implement the fix, and I’m wondering if it’s because Formtastic is being used through ActiveAdmin. So, here’s what I’ve tried to do:

In the controller, I’ve changed the method as such:

f.input :open_date, :as => :date

I also tried this, though my problem is not even being able to get to this point:

f.input :open_date, :as => :date_input

I created a file at lib/datebuilder.rb with the following code:

class DateBuilder < Formtastic::SemanticFormBuilder 
  def date_input(method, options) 
    current_value = @object.send(method) 
    html_options ||= {:value =>  current_value ? I18n.l (current_value) : @object.send("#{method}_before_type_cast")} 
    self.label(method, options.delete(:label), options.slice (:required)) + 
    self.send(:text_field, method, html_options) 
  end 
end 

I’m not sure that will even fix the format as I want, but I assume if I can just get Formtastic to use this method I can alter it as needed (currently took this from the solution mentioned in link above).

This article mentions you need to add a line to your formtastic intializer to use this custom input:

Formtastic::SemanticFormHelper.builder = Formtastic::DateBuilder

I did not have this initializer file in config/initializers so I added it (config/initializers/formtastic.rb) with the line above. The problem I am now running into is this error when trying to startup the Rails app:

../config/initializers/formtastic.rb:1:in '<top (required)>': uninitialized constant Formtastic::SemanticFormHelper (NameError)

I have also tried this syntax in that file instead:

module Formtastic
  module SemanticFormHelper
    self.builder = DateBuilder
  end
end

which gives me this error instead: ../config/initializers/formtastic.rb:3:in '<module:SemanticFormHelper>': uninitialized constant Formtastic::SemanticFormHelper::DateBuilder (NameError)

If I’m going about this in completely the wrong way please let me know, otherwise any help on getting Formtastic to use this custom input type would be amazing!

  • 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-11T11:22:12+00:00Added an answer on June 11, 2026 at 11:22 am

    Alright, finally figured out the right way to do this.

    My controller stayed the same as seen above in the update. However, here’s what I changed the DatePicker custom input file (app/inputs/date_picker_input.rb) to look like:

    class DatePickerInput < Formtastic::Inputs::StringInput
      def to_html
        "<li class='string input required stringish' id='question_#{method.to_s}_input'>" +
        "<label class=' label' for='question_#{method.to_s}'>#{method.to_s.gsub!(/_/, ' ').titleize}*</label>" +
        "<input id='question_#{method.to_s}' name='question[#{method.to_s}]' type='text' value='#{object.send(method)}' class='hasDatePicker'>" +
    "</li>"
      end
    end
    

    Hopefully this will help someone else running into the same problem! Btw, the hard-coded “question” and “required” is because I will only use this custom input on question objects. There is likely a way to dynamically get this information, but I decided against putting more work in to figure that out (this was enough of a headache on its own!)

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

Sidebar

Related Questions

UPDATE: I found that the easiest way is to use AQuery . I need
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
UPDATE: I found this enormously helpful article explaining canvas per-pixel collision detection. I'm working
UPDATE 6/21/12 I have a form in rails that is working similar to an
UPDATE This is an old question for an old version of Xcode. It turned
Update: I was able to solve this problem. I just remembered VBA use *
Update: Tried November CTP release. Same error message. Forgot to mention that this server
UPDATE Flexslider has a bunch of callback spaces for use which make this possible.
UPDATE: I found a Scipy Recipe based in this question! So, for anyone interested,
Update: Is there a way to achieve what I'm trying to do in an

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.