Class: Conjoin::FormBuilder::Input
- Inherits:
-
Object
- Object
- Conjoin::FormBuilder::Input
- Defined in:
- lib/conjoin/form_builder.rb
Direct Known Subclasses
CheckboxInput, DateInput, DecimalInput, FileInput, HiddenInput, IntegerInput, PasswordInput, RadioInput, SelectInput, StringInput, 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
290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/conjoin/form_builder.rb', line 290 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.
288 289 290 |
# File 'lib/conjoin/form_builder.rb', line 288 def app @app end |
#data ⇒ Object
Returns the value of attribute data.
288 289 290 |
# File 'lib/conjoin/form_builder.rb', line 288 def data @data end |
#options ⇒ Object
Returns the value of attribute options.
288 289 290 |
# File 'lib/conjoin/form_builder.rb', line 288 def @options end |
#record ⇒ Object
Returns the value of attribute record.
288 289 290 |
# File 'lib/conjoin/form_builder.rb', line 288 def record @record end |
Instance Method Details
#display ⇒ Object
329 330 331 |
# File 'lib/conjoin/form_builder.rb', line 329 def display mab { input } end |
#errors? ⇒ Boolean
316 317 318 |
# File 'lib/conjoin/form_builder.rb', line 316 def errors? data.errors end |
#id ⇒ Object
305 306 307 |
# File 'lib/conjoin/form_builder.rb', line 305 def id data.name.gsub(/[^a-z0-9]/, '_').gsub(/__/, '_').gsub(/_$/, '') end |
#nested_name ⇒ Object
309 310 311 312 313 314 |
# File 'lib/conjoin/form_builder.rb', line 309 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
320 321 322 323 324 325 326 327 |
# File 'lib/conjoin/form_builder.rb', line 320 def render if [:type] == :hidden \ or (.key?(:wrapper) and [:wrapper] == false) [:class] = [:class].gsub(/form-control/, '') end display end |