module
Amber::Controller::Helpers::FormHelpers
Direct including types
Defined in:
amber/controller/helpers/form_helpers.crInstance Method Summary
-
#checkbox(name : String, checked : Bool = false, **attrs) : String
Generates a checkbox input field.
-
#email_field(name : String, value : String | Nil = nil, **attrs) : String
Generates an email input field.
-
#form_for(action : String, method : String = "POST", **attrs, &block : -> String) : String
Generates an HTML form tag with automatic CSRF token inclusion.
-
#hidden_field(name : String, value : String) : String
Generates a hidden input field.
-
#label(for_field : String, text : String | Nil = nil, **attrs) : String
Generates a label element.
-
#number_field(name : String, value : Number | Nil = nil, **attrs) : String
Generates a number input field.
-
#password_field(name : String, **attrs) : String
Generates a password input field.
-
#radio_button(name : String, value : String, checked : Bool = false, **attrs) : String
Generates a radio button input field.
-
#select_field(name : String, options : Array, selected : String | Nil = nil, **attrs) : String
Generates a select dropdown field.
-
#submit_button(text : String = "Submit", **attrs) : String
Generates a submit button.
-
#text_area(name : String, value : String | Nil = nil, **attrs) : String
Generates a textarea element.
-
#text_field(name : String, value : String | Nil = nil, **attrs) : String
Generates a text input field.
Instance Method Detail
Generates a checkbox input field.
checkbox("remember_me") # => "<input type=\"checkbox\" name=\"remember_me\" id=\"remember_me\" />"
checkbox("terms", checked: true) # => "<input type=\"checkbox\" name=\"terms\" id=\"terms\" checked />"
Generates an email input field.
Generates an HTML form tag with automatic CSRF token inclusion.
For non-GET/POST methods, a hidden _method field is emitted.
form_for("/users", method: "POST") { "<input />" }
Generates a label element.
label("email") # => "<label for=\"email\">Email</label>"
label("email", text: "Your Email") # => "<label for=\"email\">Your Email</label>"
Generates a number input field.
Generates a password input field. Never includes a value attribute.
Generates a radio button input field.
radio_button("color", "red") # => "<input type=\"radio\" name=\"color\" id=\"color_red\" value=\"red\" />"
radio_button("color", "blue", checked: true) # => "<input type=\"radio\" name=\"color\" id=\"color_blue\" value=\"blue\" checked />"
Generates a select dropdown field.
select_field("color", [{"Red", "red"}, {"Blue", "blue"}], selected: "blue")
select_field("size", ["Small", "Medium", "Large"])
Generates a submit button.
submit_button # => "<input type=\"submit\" value=\"Submit\" />"
submit_button("Save") # => "<input type=\"submit\" value=\"Save\" />"
submit_button("Go", class: "btn") # => "<input type=\"submit\" value=\"Go\" class=\"btn\" />"
Generates a textarea element.
text_area("bio") # => "<textarea name=\"bio\" id=\"bio\"></textarea>"
text_area("bio", value: "Hello") # => "<textarea name=\"bio\" id=\"bio\">Hello</textarea>"
Generates a text input field.
text_field("name") # => "<input type=\"text\" name=\"name\" id=\"name\" />"
text_field("name", value: "John") # => "<input type=\"text\" name=\"name\" id=\"name\" value=\"John\" />"
text_field("name", class: "form-control") # => "<input type=\"text\" name=\"name\" id=\"name\" class=\"form-control\" />"