class ViewModel::FormBuilder

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.cr

Constructors

Instance Method Summary

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

Constructor Detail

def self.new(io, name, url, method, options = {} of String => String) #

[View source]

Instance Method Detail

def checkbox_field(name, value = false, options = {} of String => String) : Void #

[View source]
def date_field(name, value = nil, options = {} of String => String) #

[View source]
def email_field(name, options = {} of String => String) #

[View source]
def file_field(name, options = {} of String => String) #

[View source]
def hidden_field(name, value = "", options = {} of String => String) : Void #

[View source]
def io : String::Builder #

[View source]
def io=(io : String::Builder) #

[View source]
def label_for(name, text : String? = nil, options = {} of String => String) #

[View source]
def label_for(name, options = {} of String => String, &block) #

[View source]
def number_field(name, value = nil, options = {} of String => String) #

[View source]
def password_field(name, options = {} of String => String) #

[View source]
def radio_field(name, value = false, options = {} of String => String) #

[View source]
def render(&block) #

Renders form tag and yields itself to the block.


[View source]
def select_field(name, opts, value = nil, options = {} of String => String) #

[View source]
def submit(value, options = {} of String => String) #

[View source]
def text_area_field(name, text = "", options = {} of String => String) #

[View source]
def text_field(name, value = "", options = {} of String => String) : Void #

[View source]
def time_field(name, value = nil, options = {} of String => String) #

[View source]