Class: Conjoin::FormBuilder::Input
- Inherits:
-
Object
- Object
- Conjoin::FormBuilder::Input
- Defined in:
- lib/conjoin/form_builder.rb
Direct Known Subclasses
CheckboxInput, DateInput, DatetimeInput, DecimalInput, DisplayInput, FileInput, HiddenInput, IntegerInput, PasswordInput, RadioInput, SelectInput, StringInput, TextInput, TimeInput
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#data ⇒ Object
Returns the value of attribute data.
-
#options ⇒ Object
Returns the value of attribute options.
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
- #display ⇒ Object
- #errors? ⇒ Boolean
- #id ⇒ Object
-
#initialize(data, app, record) ⇒ Input
constructor
A new instance of Input.
- #nested_name ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(data, app, record) ⇒ Input
Returns a new instance of Input.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/conjoin/form_builder.rb', line 297 def initialize data, app, record @data = data @app = app @record = record @options = { name: data.name, type: :text, id: id, value: data.value, class: '' }.merge! data. [:class] += ' form-control' @options end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
295 296 297 |
# File 'lib/conjoin/form_builder.rb', line 295 def app @app end |
#data ⇒ Object
Returns the value of attribute data.
295 296 297 |
# File 'lib/conjoin/form_builder.rb', line 295 def data @data end |
#options ⇒ Object
Returns the value of attribute options.
295 296 297 |
# File 'lib/conjoin/form_builder.rb', line 295 def @options end |
#record ⇒ Object
Returns the value of attribute record.
295 296 297 |
# File 'lib/conjoin/form_builder.rb', line 295 def record @record end |
Instance Method Details
#display ⇒ Object
336 337 338 |
# File 'lib/conjoin/form_builder.rb', line 336 def display mab { input } end |
#errors? ⇒ Boolean
323 324 325 |
# File 'lib/conjoin/form_builder.rb', line 323 def errors? data.errors end |
#id ⇒ Object
312 313 314 |
# File 'lib/conjoin/form_builder.rb', line 312 def id data.name.gsub(/[^a-z0-9]/, '_').gsub(/__/, '_').gsub(/_$/, '') end |
#nested_name ⇒ Object
316 317 318 319 320 321 |
# File 'lib/conjoin/form_builder.rb', line 316 def nested_name # create field names that map to the correct models data.names.each_with_index.map do |field, i| i != 0 ? "[#{field}]" : field end.join end |
#render ⇒ Object
327 328 329 330 331 332 333 334 |
# File 'lib/conjoin/form_builder.rb', line 327 def render if [:type] == :hidden \ or (.key?(:wrapper) and [:wrapper] == false) [:class] = [:class].gsub(/form-control/, '') end display end |