elandesign / formtastic_calendar Goto Github PK
View Code? Open in Web Editor NEWAn input plugin for Formtastic to render date fields using the Rails Date Kit.
License: MIT License
An input plugin for Formtastic to render date fields using the Rails Date Kit.
License: MIT License
This looks super helpful and a promising compliment to formtastic.
I'm running into an issue and I'm not sure if it has to do a missing dependency or if something else might be going on.
undefined method input_simple' for #<Formtastic::SemanticFormBuilder:0x0000000ce47f58> /vendor/plugins/formtastic_calendar/lib/formtastic_calendar.rb:12:in
calendar_input'
besides the plugin install I have added the Rails Date Kit Helper and the made sure it was referenced in the application controller.
I'll keep looking at this but I was just wondering if I was missing something that might not have been called out in the docs yet or if someone else has encountered this.
Thanks
The calendar works great and definitely inputs into fields as advertised.
My only problem at the moment is that if you do not input a date field via the calendar, the submitted form throws a nil object exception rather than hitting the validations I've put in and telling you you need to put in a TOIL date.
Is there a way around this or have I missed something I needed to do to hook it up to validations ?
Great work though. Really loving the UX is adds to the app.
thanks,
Daryl.
Maybe this is for the Rails Date Kit
As there's no way to specify that a transient property should be a 'Date', the calendar plugin should deal with the case when the value is of type String -- currently it crashes even with the use of .try(). Here's my patch for formtastic_calendar.rb:
def calendar_options(format, value = nil)
months = '[' + Date::MONTHNAMES[1..12].collect { |m| "'#{m}'" }.join(',') + ']'
days = '[' + Date::DAYNAMES.collect { |d| "'#{d}'" }.join(',') + ']'
# BEGIN CHANGE
value_string = value
unless value.nil?
value_string = value.try(:strftime, format) if value.is_a?(Date)
end
calendar_options = { :input_html =>
{
:onfocus => "this.select();calendar_open(this,{format:'#{format}'," +
"images_dir:'/images',month_names:#{months},day_names:#{days}})",
:onclick => "event.cancelBubble=true;this.select();calendar_open("+
"this,{format:'#{format}',images_dir:'/images',"+
"month_names:#{months},day_names:#{days}})",
:value => value_string
}
}
#END CHANGE
end
I am not a java script expert, but is their a place where I can change the first day of the week (currently set to Sunday) to Monday. But this the calandar would start with Monday, not Sunday (very common in europe)
Any help would be appreciated.
Chriss
I love the plugin, just what I need. but where can I add the Time.
Cheers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.