class ViewModel::FormBuilder
- ViewModel::FormBuilder
- Reference
- Object
Overview
Default form builder.
All methods print data to io and return nil
that's why it is not necessary to add their return value
to context String::Builder
.
Each field gets HTML classes based on it's name, type and form name.
- build_form :user do |f|
- f.text_field :name # "vm-form-input vm-form-text user-name"
Included Modules
Defined in:
view_model/form_builder.crConstructors
Instance Method Summary
- #checkbox_field(name, value = false, options = {} of String => String) : Void
- #date_field(name, value = nil, options = {} of String => String)
- #email_field(name, options = {} of String => String)
- #file_field(name, options = {} of String => String)
- #hidden_field(name, value = "", options = {} of String => String) : Void
- #io : String::Builder
- #io=(io : String::Builder)
- #label_for(name, text : String? = nil, options = {} of String => String)
- #label_for(name, options = {} of String => String, &block)
- #number_field(name, value = nil, options = {} of String => String)
- #password_field(name, options = {} of String => String)
- #radio_field(name, value = false, options = {} of String => String)
-
#render(&block)
Renders form tag and yields itself to the block.
- #select_field(name, opts, value = nil, options = {} of String => String)
- #submit(value, options = {} of String => String)
- #text_area_field(name, text = "", options = {} of String => String)
- #text_field(name, value = "", options = {} of String => String) : Void
- #time_field(name, value = nil, options = {} of String => String)
Instance methods inherited from module ViewModel::FormTags
checkbox_tag(name : String | Symbol, value = nil, options = SHash.new)checkbox_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) checkbox_tag, content_tag(io : String::Builder, tag, html_options = SHash.new)
content_tag(tag, html_options : Hash = {} of String => String)
content_tag(io : String::Builder, tag, html_options = SHash.new, &block)
content_tag(tag, html_options : Hash = {} of String => String, &block) content_tag, date_tag(name : String | Symbol, value = nil, options = SHash.new)
date_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) date_tag, email_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new)
email_tag(name : String | Symbol, value = nil, options = SHash.new) email_tag, file_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new)
file_tag(name : String | Symbol, value = nil, options = SHash.new) file_tag, hidden_tag(name : String | Symbol, value = nil, options = SHash.new)
hidden_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) hidden_tag, label_tag(io : String::Builder, for : Symbol | String? = nil, html_options = SHash.new, &block)
label_tag(io : String::Builder, text, for : Symbol | String? = nil, html_options = SHash.new)
label_tag(text, for : Symbol | String? = nil, html_options = {} of String => String)
label_tag(for : Symbol | String? = nil, html_options = SHash.new, &block) label_tag, number_tag(name : String | Symbol, value = nil, options = SHash.new)
number_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) number_tag, password_tag(name : String | Symbol, value = nil, options = SHash.new)
password_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) password_tag, radio_tag(name : String | Symbol, value = nil, options = SHash.new)
radio_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) radio_tag, select_tag(io : String::Builder, name : String | Symbol, options : Array(Array), value = nil, html_options = SHash.new)
select_tag(name, options : Array(Array), value = nil, html_options = {} of String => String) select_tag, submit_tag(name : String | Symbol, value = nil, options = SHash.new)
submit_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) submit_tag, text_area_tag(io : String::Builder, name, text = "", html_options = {} of String => String)
text_area_tag(name, text = "", html_options = {} of String => String) text_area_tag, text_tag(name : String | Symbol, value = nil, options = SHash.new)
text_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) text_tag, time_tag(name : String | Symbol, value = nil, options = SHash.new)
time_tag(io : String::Builder, name : String | Symbol, value = nil, options = SHash.new) time_tag