Top Level Namespace

Defined in:

Macro Summary

Macro Detail

macro button(decl, **options) #

Generates a button field for a Kemal::Form class. A button can take 2 optional arguments/options; text and args.

text: The text content of the button. args: A hash of attributes to add to the button.

class CustomForm < Kemal::Form
  button submit : Kemal::Form::SubmitButton,
                  text: "Login",
                  args: {"class" => "btn btn-primary"}
end

[View source]
macro field(decl, **opts) #

Generates a field for a Kemal::Form class. A field can take a couple of optional arguments/options; id, name, attrs, value, required, validators and label.

id: The value of the id attribute. name: The value of the name attribute. attrs: A hash of additional attributes to add to the field. value: The value of the field. required: A boolean that tells if the required attribute should be added to the field (default: false). validators: An array of Kemal::FormValidator::Validator. label: Custom field label (Kemal::Form::Label).

class CustomForm < Kemal::Form
  field name : Kemal::Form::TextField
end

[View source]