sensis-formtastic-rails3 1.d4e5326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.textile +584 -0
- data/Rakefile +127 -0
- data/generators/form/USAGE +16 -0
- data/generators/form/form_generator.rb +120 -0
- data/generators/form/templates/view__form.html.erb +5 -0
- data/generators/form/templates/view__form.html.haml +4 -0
- data/generators/formtastic/formtastic_generator.rb +24 -0
- data/generators/formtastic/templates/formtastic.css +131 -0
- data/generators/formtastic/templates/formtastic.rb +54 -0
- data/generators/formtastic/templates/formtastic_changes.css +14 -0
- data/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +16 -0
- data/init.rb +5 -0
- data/lib/formtastic.rb +1870 -0
- data/lib/formtastic/i18n.rb +35 -0
- data/lib/formtastic/layout_helper.rb +10 -0
- data/lib/formtastic/railtie.rb +12 -0
- data/lib/formtastic/util.rb +36 -0
- data/lib/generators/formtastic/form/form_generator.rb +86 -0
- data/lib/generators/formtastic/install/install_generator.rb +24 -0
- data/lib/locale/en.yml +8 -0
- data/rails/init.rb +2 -0
- data/spec/buttons_spec.rb +166 -0
- data/spec/commit_button_spec.rb +401 -0
- data/spec/custom_builder_spec.rb +98 -0
- data/spec/defaults_spec.rb +20 -0
- data/spec/error_proc_spec.rb +27 -0
- data/spec/errors_spec.rb +105 -0
- data/spec/form_helper_spec.rb +142 -0
- data/spec/helpers/layout_helper_spec.rb +21 -0
- data/spec/i18n_spec.rb +152 -0
- data/spec/include_blank_spec.rb +74 -0
- data/spec/input_spec.rb +786 -0
- data/spec/inputs/boolean_input_spec.rb +104 -0
- data/spec/inputs/check_boxes_input_spec.rb +426 -0
- data/spec/inputs/country_input_spec.rb +118 -0
- data/spec/inputs/date_input_spec.rb +168 -0
- data/spec/inputs/datetime_input_spec.rb +310 -0
- data/spec/inputs/file_input_spec.rb +34 -0
- data/spec/inputs/hidden_input_spec.rb +78 -0
- data/spec/inputs/numeric_input_spec.rb +44 -0
- data/spec/inputs/password_input_spec.rb +46 -0
- data/spec/inputs/radio_input_spec.rb +243 -0
- data/spec/inputs/select_input_spec.rb +546 -0
- data/spec/inputs/string_input_spec.rb +64 -0
- data/spec/inputs/text_input_spec.rb +34 -0
- data/spec/inputs/time_input_spec.rb +206 -0
- data/spec/inputs/time_zone_input_spec.rb +110 -0
- data/spec/inputs_spec.rb +476 -0
- data/spec/label_spec.rb +89 -0
- data/spec/semantic_errors_spec.rb +98 -0
- data/spec/semantic_fields_for_spec.rb +45 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +289 -0
- data/spec/support/custom_macros.rb +494 -0
- data/spec/support/output_buffer.rb +4 -0
- data/spec/support/test_environment.rb +45 -0
- metadata +234 -0
data/Rakefile
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
gem 'rspec', '>= 1.2.6'
|
8
|
+
gem 'rspec-rails', '>= 1.2.6'
|
9
|
+
require 'spec'
|
10
|
+
require 'spec/rake/spectask'
|
11
|
+
rescue LoadError
|
12
|
+
begin
|
13
|
+
require 'rspec/core/rake_task.rb'
|
14
|
+
require 'rspec/core/version'
|
15
|
+
rescue LoadError
|
16
|
+
puts "[formtastic:] RSpec - or one of it's dependencies - is not available. Install it with: sudo gem install rspec-rails"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
begin
|
21
|
+
GEM = "formtastic"
|
22
|
+
AUTHOR = "Justin French"
|
23
|
+
EMAIL = "justin@indent.com.au"
|
24
|
+
SUMMARY = "A Rails form builder plugin/gem with semantically rich and accessible markup"
|
25
|
+
HOMEPAGE = "http://github.com/justinfrench/formtastic/tree/master"
|
26
|
+
INSTALL_MESSAGE = %q{
|
27
|
+
========================================================================
|
28
|
+
Thanks for installing Formtastic!
|
29
|
+
------------------------------------------------------------------------
|
30
|
+
You can now (optionally) run the generator to copy some stylesheets and
|
31
|
+
a config initializer into your application:
|
32
|
+
rails generator formastic:install # Rails 3
|
33
|
+
./script/generate formtastic # Rails 2
|
34
|
+
|
35
|
+
To generate some semantic form markup for your existing models, just run:
|
36
|
+
rails generate formtastic:form MODEL_NAME # Rails 3
|
37
|
+
./script/generate form MODEL_NAME # Rails 2
|
38
|
+
|
39
|
+
Find out more and get involved:
|
40
|
+
http://github.com/justinfrench/formtastic
|
41
|
+
http://groups.google.com.au/group/formtastic
|
42
|
+
========================================================================
|
43
|
+
}
|
44
|
+
|
45
|
+
gem 'jeweler', '>= 1.0.0'
|
46
|
+
require 'jeweler'
|
47
|
+
|
48
|
+
Jeweler::Tasks.new do |s|
|
49
|
+
s.name = GEM
|
50
|
+
s.summary = SUMMARY
|
51
|
+
s.email = EMAIL
|
52
|
+
s.homepage = HOMEPAGE
|
53
|
+
s.description = SUMMARY
|
54
|
+
s.author = AUTHOR
|
55
|
+
s.post_install_message = INSTALL_MESSAGE
|
56
|
+
|
57
|
+
s.require_path = 'lib'
|
58
|
+
s.files = %w(MIT-LICENSE README.textile Rakefile init.rb) + Dir.glob("{rails,lib,generators,spec}/**/*")
|
59
|
+
|
60
|
+
# Runtime dependencies: When installing Formtastic these will be checked if they are installed.
|
61
|
+
# Will be offered to install these if they are not already installed.
|
62
|
+
s.add_dependency 'activesupport', '>= 2.3.0'
|
63
|
+
s.add_dependency 'actionpack', '>= 2.3.0'
|
64
|
+
s.add_dependency 'i18n', '>= 0.4.0'
|
65
|
+
|
66
|
+
# Development dependencies. Not installed by default.
|
67
|
+
# Install with: sudo gem install formtastic --development
|
68
|
+
s.add_development_dependency 'rspec-rails', '>= 1.2.6'
|
69
|
+
s.add_development_dependency 'rspec_tag_matchers', '>= 1.0.0'
|
70
|
+
end
|
71
|
+
|
72
|
+
Jeweler::GemcutterTasks.new
|
73
|
+
rescue LoadError
|
74
|
+
puts "[formtastic:] Jeweler - or one of its dependencies - is not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Default: run unit specs.'
|
78
|
+
task :default => :spec
|
79
|
+
|
80
|
+
desc 'Generate documentation for the formtastic plugin.'
|
81
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
82
|
+
rdoc.rdoc_dir = 'rdoc'
|
83
|
+
rdoc.title = 'Formtastic'
|
84
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
85
|
+
rdoc.rdoc_files.include('README.textile')
|
86
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
87
|
+
end
|
88
|
+
|
89
|
+
if defined?(Spec)
|
90
|
+
desc 'Test the formtastic plugin.'
|
91
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
92
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
93
|
+
t.spec_opts = ["-c"]
|
94
|
+
end
|
95
|
+
|
96
|
+
desc 'Test the formtastic plugin with specdoc formatting and colors'
|
97
|
+
Spec::Rake::SpecTask.new('specdoc') do |t|
|
98
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
99
|
+
t.spec_opts = ["--format specdoc", "-c"]
|
100
|
+
end
|
101
|
+
|
102
|
+
desc "Run all examples with RCov"
|
103
|
+
Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
|
104
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
105
|
+
t.rcov = true
|
106
|
+
t.rcov_opts = ['--exclude', 'spec,Library']
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
if defined?(RSpec)
|
111
|
+
desc 'Test the formtastic plugin.'
|
112
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
113
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
114
|
+
end
|
115
|
+
|
116
|
+
desc 'Test the formtastic plugin with specdoc formatting and colors'
|
117
|
+
RSpec::Core::RakeTask.new('specdoc') do |t|
|
118
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "Run all examples with RCov"
|
122
|
+
RSpec::Core::RakeTask.new('examples_with_rcov') do |t|
|
123
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
124
|
+
t.rcov = true
|
125
|
+
t.rcov_opts = ['--exclude', 'spec,Library']
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
NAME
|
2
|
+
form - Formtastic form generator.
|
3
|
+
|
4
|
+
DESCRIPTION
|
5
|
+
Generates formtastic form code based on an existing model. By default the generated code will be printed out directly in the terminal, and also copied to clipboard. Can optionally be saved into partial directly.
|
6
|
+
|
7
|
+
Required:
|
8
|
+
ExistingModelName - The name of an existing model for which the generator should generate form code.
|
9
|
+
|
10
|
+
Options:
|
11
|
+
--haml Generate HAML instead of ERB.
|
12
|
+
--partial Generate a form partial in the model views path, i.e. "_form.html.erb" or _form.html.haml".
|
13
|
+
--controller PATH Generate for custom controller/view path - in case model and controller namespace is different, i.e. "admin/posts".
|
14
|
+
|
15
|
+
EXAMPLE
|
16
|
+
./script/generate form ExistingModelName [--haml] [--partial]
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Get current OS - needed for clipboard functionality
|
3
|
+
case RUBY_PLATFORM
|
4
|
+
when /darwin/ then
|
5
|
+
CURRENT_OS = :osx
|
6
|
+
when /win32/
|
7
|
+
CURRENT_OS = :win
|
8
|
+
begin
|
9
|
+
require 'win32/clipboard'
|
10
|
+
rescue LoadError
|
11
|
+
# Do nothing
|
12
|
+
end
|
13
|
+
else
|
14
|
+
CURRENT_OS = :x
|
15
|
+
end
|
16
|
+
|
17
|
+
class FormGenerator < Rails::Generator::NamedBase
|
18
|
+
|
19
|
+
default_options :haml => false,
|
20
|
+
:partial => false
|
21
|
+
|
22
|
+
VIEWS_PATH = File.join('app', 'views').freeze
|
23
|
+
IGNORED_COLUMNS = [:updated_at, :created_at].freeze
|
24
|
+
|
25
|
+
attr_reader :controller_file_name,
|
26
|
+
:controller_class_path,
|
27
|
+
:controller_class_nesting,
|
28
|
+
:controller_class_nesting_depth,
|
29
|
+
:controller_class_name,
|
30
|
+
:template_type
|
31
|
+
|
32
|
+
def initialize(runtime_args, runtime_options = {})
|
33
|
+
super
|
34
|
+
base_name, @controller_class_path = extract_modules(@name.pluralize)
|
35
|
+
controller_class_name_without_nesting, @controller_file_name = inflect_names(base_name)
|
36
|
+
@template_type = options[:haml] ? :haml : :erb
|
37
|
+
end
|
38
|
+
|
39
|
+
def manifest
|
40
|
+
record do |m|
|
41
|
+
if options[:partial]
|
42
|
+
controller_and_view_path = options[:controller] || File.join(controller_class_path, controller_file_name)
|
43
|
+
# Ensure directory exists.
|
44
|
+
m.directory File.join(VIEWS_PATH, controller_and_view_path)
|
45
|
+
# Create a form partial for the model as "_form" in it's views path.
|
46
|
+
m.template "view__form.html.#{template_type}", File.join(VIEWS_PATH, controller_and_view_path, "_form.html.#{template_type}")
|
47
|
+
else
|
48
|
+
# Load template file, and render without saving to file
|
49
|
+
template = File.read(File.join(source_root, "view__form.html.#{template_type}"))
|
50
|
+
erb = ERB.new(template, nil, '-')
|
51
|
+
generated_code = erb.result(binding).strip rescue nil
|
52
|
+
|
53
|
+
# Print the result, and copy to clipboard
|
54
|
+
puts "# ---------------------------------------------------------"
|
55
|
+
puts "# GENERATED FORMTASTIC CODE"
|
56
|
+
puts "# ---------------------------------------------------------"
|
57
|
+
puts
|
58
|
+
puts generated_code || " Nothing could be generated - model exists?"
|
59
|
+
puts
|
60
|
+
puts "# ---------------------------------------------------------"
|
61
|
+
puts " Copied to clipboard - just paste it!" if save_to_clipboard(generated_code)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
|
68
|
+
# Save to lipboard with multiple OS support.
|
69
|
+
def save_to_clipboard(data)
|
70
|
+
return unless data
|
71
|
+
begin
|
72
|
+
case CURRENT_OS
|
73
|
+
when :osx
|
74
|
+
`echo "#{data}" | pbcopy`
|
75
|
+
when :win
|
76
|
+
::Win32::Clipboard.data = data
|
77
|
+
else # :linux/:unix
|
78
|
+
`echo "#{data}" | xsel --clipboard` || `echo "#{data}" | xclip`
|
79
|
+
end
|
80
|
+
rescue
|
81
|
+
false
|
82
|
+
else
|
83
|
+
true
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Add additional model attributes if specified in args - probably not that common scenario.
|
88
|
+
def attributes
|
89
|
+
# Get columns for the requested model.
|
90
|
+
existing_attributes = @class_name.constantize.content_columns.reject { |column| IGNORED_COLUMNS.include?(column.name.to_sym) }
|
91
|
+
@args = super + existing_attributes
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_options!(opt)
|
95
|
+
opt.separator ''
|
96
|
+
opt.separator 'Options:'
|
97
|
+
|
98
|
+
# Allow option to generate HAML views instead of ERB.
|
99
|
+
opt.on('--haml',
|
100
|
+
"Generate HAML output instead of the default ERB.") do |v|
|
101
|
+
options[:haml] = v
|
102
|
+
end
|
103
|
+
|
104
|
+
# Allow option to generate to partial in model's views path, instead of printing out in terminal.
|
105
|
+
opt.on('--partial',
|
106
|
+
"Save generated output directly to a form partial (app/views/{resource}/_form.html.*).") do |v|
|
107
|
+
options[:partial] = v
|
108
|
+
end
|
109
|
+
|
110
|
+
opt.on('--controller CONTROLLER_PATH',
|
111
|
+
"Specify a non-standard controller for the specified model (e.g. admin/posts).") do |v|
|
112
|
+
options[:controller] = v if v.present?
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def banner
|
117
|
+
"Usage: #{$0} form ExistingModelName [--haml] [--partial]"
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class FormtasticGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
def initialize(*runtime_args)
|
4
|
+
super
|
5
|
+
end
|
6
|
+
|
7
|
+
def manifest
|
8
|
+
record do |m|
|
9
|
+
m.directory File.join('config', 'initializers')
|
10
|
+
m.template 'formtastic.rb', File.join('config', 'initializers', 'formtastic.rb')
|
11
|
+
|
12
|
+
m.directory File.join('public', 'stylesheets')
|
13
|
+
m.template 'formtastic.css', File.join('public', 'stylesheets', 'formtastic.css')
|
14
|
+
m.template 'formtastic_changes.css', File.join('public', 'stylesheets', 'formtastic_changes.css')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def banner
|
21
|
+
%{Usage: #{$0} #{spec.name}\nCopies formtastic.css and formtastic_changes.css to public/stylesheets/ and a config initializer to config/initializers/formtastic.rb}
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
/* -------------------------------------------------------------------------------------------------
|
2
|
+
|
3
|
+
It's *strongly* suggested that you don't modify this file. Instead, load a new stylesheet after
|
4
|
+
this one in your layouts (eg formtastic_changes.css) and override the styles to suit your needs.
|
5
|
+
This will allow you to update formtastic.css with new releases without clobbering your own changes.
|
6
|
+
|
7
|
+
This stylesheet forms part of the Formtastic Rails Plugin
|
8
|
+
(c) 2008 Justin French
|
9
|
+
|
10
|
+
--------------------------------------------------------------------------------------------------*/
|
11
|
+
|
12
|
+
|
13
|
+
/* NORMALIZE AND RESET - obviously inspired by Yahoo's reset.css, but scoped to just form.formtastic
|
14
|
+
--------------------------------------------------------------------------------------------------*/
|
15
|
+
form.formtastic, form.formtastic ul, form.formtastic ol, form.formtastic li, form.formtastic fieldset, form.formtastic legend, form.formtastic input, form.formtastic textarea, form.formtastic select, form.formtastic p { margin:0; padding:0; }
|
16
|
+
form.formtastic fieldset { border:0; }
|
17
|
+
form.formtastic em, form.formtastic strong { font-style:normal; font-weight:normal; }
|
18
|
+
form.formtastic ol, form.formtastic ul { list-style:none; }
|
19
|
+
form.formtastic abbr, form.formtastic acronym { border:0; font-variant:normal; }
|
20
|
+
form.formtastic input, form.formtastic textarea, form.formtastic select { font-family:inherit; font-size:inherit; font-weight:inherit; }
|
21
|
+
form.formtastic input, form.formtastic textarea, form.formtastic select { font-size:100%; }
|
22
|
+
form.formtastic legend { white-space:normal; color:#000; }
|
23
|
+
|
24
|
+
|
25
|
+
/* SEMANTIC ERRORS
|
26
|
+
--------------------------------------------------------------------------------------------------*/
|
27
|
+
form.formtastic ul.errors { color:#cc0000; margin:0.5em 0 1.5em 25%; list-style:square; }
|
28
|
+
form.formtastic ul.errors li { padding:0; border:none; display:list-item; }
|
29
|
+
|
30
|
+
|
31
|
+
/* FIELDSETS & LISTS
|
32
|
+
--------------------------------------------------------------------------------------------------*/
|
33
|
+
form.formtastic fieldset { overflow:auto; } /* clearing contained floats */
|
34
|
+
form.formtastic fieldset.inputs { }
|
35
|
+
form.formtastic fieldset.buttons { padding-left:25%; }
|
36
|
+
form.formtastic fieldset ol { }
|
37
|
+
form.formtastic fieldset.buttons li { float:left; padding-right:0.5em; }
|
38
|
+
|
39
|
+
/* INPUT LIs
|
40
|
+
--------------------------------------------------------------------------------------------------*/
|
41
|
+
form.formtastic fieldset > ol > li { margin-bottom:1.5em; }
|
42
|
+
form.formtastic fieldset > ol > li { overflow:auto; } /* clearing contained floats */
|
43
|
+
|
44
|
+
form.formtastic fieldset > ol > li.required { }
|
45
|
+
form.formtastic fieldset > ol > li.optional { }
|
46
|
+
form.formtastic fieldset > ol > li.error { }
|
47
|
+
|
48
|
+
|
49
|
+
/* LABELS
|
50
|
+
--------------------------------------------------------------------------------------------------*/
|
51
|
+
form.formtastic fieldset > ol > li label { display:block; width:25%; float:left; padding-top:.2em; }
|
52
|
+
form.formtastic fieldset > ol > li > li label { line-height:100%; padding-top:0; }
|
53
|
+
form.formtastic fieldset > ol > li > li label input { line-height:100%; vertical-align:middle; margin-top:-0.1em;}
|
54
|
+
|
55
|
+
|
56
|
+
/* NESTED FIELDSETS AND LEGENDS (radio, check boxes and date/time inputs use nested fieldsets)
|
57
|
+
--------------------------------------------------------------------------------------------------*/
|
58
|
+
form.formtastic fieldset > ol > li fieldset { position:relative; }
|
59
|
+
form.formtastic fieldset > ol > li fieldset legend { position:absolute; width:95%; padding-top:0.1em; left: 0px; }
|
60
|
+
form.formtastic fieldset > ol > li fieldset legend span { position:absolute; }
|
61
|
+
form.formtastic fieldset > ol > li fieldset legend.label label { position:absolute; }
|
62
|
+
form.formtastic fieldset > ol > li fieldset ol { float:left; width:74%; margin:0; padding:0 0 0 25%; }
|
63
|
+
form.formtastic fieldset > ol > li fieldset ol li { padding:0; border:0; }
|
64
|
+
|
65
|
+
|
66
|
+
/* INLINE HINTS
|
67
|
+
--------------------------------------------------------------------------------------------------*/
|
68
|
+
form.formtastic fieldset > ol > li p.inline-hints { color:#666; margin:0.5em 0 0 25%; }
|
69
|
+
|
70
|
+
|
71
|
+
/* INLINE ERRORS
|
72
|
+
--------------------------------------------------------------------------------------------------*/
|
73
|
+
form.formtastic fieldset > ol > li p.inline-errors { color:#cc0000; margin:0.5em 0 0 25%; }
|
74
|
+
form.formtastic fieldset > ol > li ul.errors { color:#cc0000; margin:0.5em 0 0 25%; list-style:square; }
|
75
|
+
form.formtastic fieldset > ol > li ul.errors li { padding:0; border:none; display:list-item; }
|
76
|
+
|
77
|
+
|
78
|
+
/* STRING & NUMERIC OVERRIDES
|
79
|
+
--------------------------------------------------------------------------------------------------*/
|
80
|
+
form.formtastic fieldset > ol > li.string input { max-width:74%; }
|
81
|
+
form.formtastic fieldset > ol > li.password input { max-width: 13em; }
|
82
|
+
form.formtastic fieldset > ol > li.numeric input { max-width:74%; }
|
83
|
+
|
84
|
+
|
85
|
+
/* TEXTAREA OVERRIDES
|
86
|
+
--------------------------------------------------------------------------------------------------*/
|
87
|
+
form.formtastic fieldset > ol > li.text textarea { width:74%; }
|
88
|
+
|
89
|
+
|
90
|
+
/* HIDDEN OVERRIDES
|
91
|
+
--------------------------------------------------------------------------------------------------*/
|
92
|
+
form.formtastic fieldset ol li.hidden { display:none; }
|
93
|
+
|
94
|
+
/* BOOLEAN OVERRIDES
|
95
|
+
--------------------------------------------------------------------------------------------------*/
|
96
|
+
form.formtastic fieldset > ol > li.boolean label { padding-left:25%; width:auto; }
|
97
|
+
form.formtastic fieldset > ol > li.boolean label input { margin:0 0.5em 0 0.2em; }
|
98
|
+
|
99
|
+
|
100
|
+
/* RADIO OVERRIDES
|
101
|
+
--------------------------------------------------------------------------------------------------*/
|
102
|
+
form.formtastic fieldset > ol > li.radio { }
|
103
|
+
form.formtastic fieldset > ol > li.radio fieldset ol { margin-bottom:-0.6em; }
|
104
|
+
form.formtastic fieldset > ol > li.radio fieldset ol li { margin:0.1em 0 0.5em 0; }
|
105
|
+
form.formtastic fieldset > ol > li.radio fieldset ol li label { float:none; width:100%; }
|
106
|
+
form.formtastic fieldset > ol > li.radio fieldset ol li label input { margin-right:0.2em; }
|
107
|
+
|
108
|
+
|
109
|
+
/* CHECK BOXES (COLLECTION) OVERRIDES
|
110
|
+
--------------------------------------------------------------------------------------------------*/
|
111
|
+
form.formtastic fieldset > ol > li.check_boxes { }
|
112
|
+
form.formtastic fieldset > ol > li.check_boxes fieldset ol { margin-bottom:-0.6em; }
|
113
|
+
form.formtastic fieldset > ol > li.check_boxes fieldset ol li { margin:0.1em 0 0.5em 0; }
|
114
|
+
form.formtastic fieldset > ol > li.check_boxes fieldset ol li label { float:none; width:100%; }
|
115
|
+
form.formtastic fieldset > ol > li.check_boxes fieldset ol li label input { margin-right:0.2em; }
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
/* DATE & TIME OVERRIDES
|
120
|
+
--------------------------------------------------------------------------------------------------*/
|
121
|
+
form.formtastic fieldset > ol > li.date fieldset ol li,
|
122
|
+
form.formtastic fieldset > ol > li.time fieldset ol li,
|
123
|
+
form.formtastic fieldset > ol > li.datetime fieldset ol li { float:left; width:auto; margin:0 .3em 0 0; }
|
124
|
+
|
125
|
+
form.formtastic fieldset > ol > li.date fieldset ol li label,
|
126
|
+
form.formtastic fieldset > ol > li.time fieldset ol li label,
|
127
|
+
form.formtastic fieldset > ol > li.datetime fieldset ol li label { display:none; }
|
128
|
+
|
129
|
+
form.formtastic fieldset > ol > li.date fieldset ol li label input,
|
130
|
+
form.formtastic fieldset > ol > li.time fieldset ol li label input,
|
131
|
+
form.formtastic fieldset > ol > li.datetime fieldset ol li label input { display:inline; margin:0; padding:0; }
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Set the default text field size when input is a string. Default is 50.
|
2
|
+
# Formtastic::SemanticFormBuilder.default_text_field_size = 50
|
3
|
+
|
4
|
+
# Set the default text area height when input is a text. Default is 20.
|
5
|
+
# Formtastic::SemanticFormBuilder.default_text_area_height = 5
|
6
|
+
|
7
|
+
# Should all fields be considered "required" by default?
|
8
|
+
# Defaults to true, see ValidationReflection notes below.
|
9
|
+
# Formtastic::SemanticFormBuilder.all_fields_required_by_default = true
|
10
|
+
|
11
|
+
# Should select fields have a blank option/prompt by default?
|
12
|
+
# Defaults to true.
|
13
|
+
# Formtastic::SemanticFormBuilder.include_blank_for_select_by_default = true
|
14
|
+
|
15
|
+
# Set the string that will be appended to the labels/fieldsets which are required
|
16
|
+
# It accepts string or procs and the default is a localized version of
|
17
|
+
# '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
|
18
|
+
# in your locale, it will replace the abbr title properly. But if you don't want to use
|
19
|
+
# abbr tag, you can simply give a string as below
|
20
|
+
# Formtastic::SemanticFormBuilder.required_string = "(required)"
|
21
|
+
|
22
|
+
# Set the string that will be appended to the labels/fieldsets which are optional
|
23
|
+
# Defaults to an empty string ("") and also accepts procs (see required_string above)
|
24
|
+
# Formtastic::SemanticFormBuilder.optional_string = "(optional)"
|
25
|
+
|
26
|
+
# Set the way inline errors will be displayed.
|
27
|
+
# Defaults to :sentence, valid options are :sentence, :list and :none
|
28
|
+
# Formtastic::SemanticFormBuilder.inline_errors = :sentence
|
29
|
+
|
30
|
+
# Set the method to call on label text to transform or format it for human-friendly
|
31
|
+
# reading when formtastic is used without object. Defaults to :humanize.
|
32
|
+
# Formtastic::SemanticFormBuilder.label_str_method = :humanize
|
33
|
+
|
34
|
+
# Set the array of methods to try calling on parent objects in :select and :radio inputs
|
35
|
+
# for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
|
36
|
+
# that is found on the object will be used.
|
37
|
+
# Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
38
|
+
# Formtastic::SemanticFormBuilder.collection_label_methods = [
|
39
|
+
# "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
40
|
+
|
41
|
+
# Formtastic by default renders inside li tags the input, hints and then
|
42
|
+
# errors messages. Sometimes you want the hints to be rendered first than
|
43
|
+
# the input, in the following order: hints, input and errors. You can
|
44
|
+
# customize it doing just as below:
|
45
|
+
# Formtastic::SemanticFormBuilder.inline_order = [:input, :hints, :errors]
|
46
|
+
|
47
|
+
# Specifies if labels/hints for input fields automatically be looked up using I18n.
|
48
|
+
# Default value: false. Overridden for specific fields by setting value to true,
|
49
|
+
# i.e. :label => true, or :hint => true (or opposite depending on initialized value)
|
50
|
+
# Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
|
51
|
+
|
52
|
+
# You can add custom inputs or override parts of Formtastic by subclassing SemanticFormBuilder and
|
53
|
+
# specifying that class here. Defaults to SemanticFormBuilder.
|
54
|
+
# Formtastic::SemanticFormHelper.builder = MyCustomBuilder
|