Extend partial form views with optional options
This commit is contained in:
parent
f3d8426a4f
commit
07cb9dd6fe
14
stoptime.rb
14
stoptime.rb
|
@ -1739,26 +1739,28 @@ module StopTime::Views
|
||||||
# Partial view that generates a form radio button with the given _name_
|
# Partial view that generates a form radio button with the given _name_
|
||||||
# and _value_.
|
# and _value_.
|
||||||
# Whether it is initially selected is determined by the _default_ flag.
|
# Whether it is initially selected is determined by the _default_ flag.
|
||||||
def _form_input_radio(name, value, default=false)
|
# Additional options can be passed via the collection _opts_.
|
||||||
|
def _form_input_radio(name, value, default=false, *opts)
|
||||||
input_val = @input[name]
|
input_val = @input[name]
|
||||||
if input_val == value or (input_val.blank? and default)
|
if input_val == value or (input_val.blank? and default)
|
||||||
input :type => "radio", :id => "#{name}_#{value}",
|
input :type => "radio", :id => "#{name}_#{value}",
|
||||||
:name => name, :value => value, :checked => true
|
:name => name, :value => value, :checked => true, *opts
|
||||||
else
|
else
|
||||||
input :type => "radio", :id => "#{name}_#{value}",
|
input :type => "radio", :id => "#{name}_#{value}",
|
||||||
:name => name, :value => value
|
:name => name, :value => value, *opts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Partial view that generates a form checkbox with the given _name_.
|
# Partial view that generates a form checkbox with the given _name_.
|
||||||
# Whether it is initiall checked is determined by the _value_ flag.
|
# Whether it is initiall checked is determined by the _value_ flag.
|
||||||
def _form_input_checkbox(name, value=true)
|
# Additional options can be passed via the collection _opts_.
|
||||||
|
def _form_input_checkbox(name, value=true, *opts)
|
||||||
if @input[name] == value
|
if @input[name] == value
|
||||||
input :type => "checkbox", :id => "#{name}_#{value}", :name => name,
|
input :type => "checkbox", :id => "#{name}_#{value}", :name => name,
|
||||||
:value => value, :checked => true
|
:value => value, :checked => true, *opts
|
||||||
else
|
else
|
||||||
input :type => "checkbox", :id => "#{name}_#{value}", :name => name,
|
input :type => "checkbox", :id => "#{name}_#{value}", :name => name,
|
||||||
:value => value
|
:value => value, *opts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue