formz/subform

Detials about a subform being added to a form. There is a convenience function to create a field with just a name, and then you can use the rest of the functions to set just the values you need to change.

Types

pub type SubForm {
  SubForm(name: String, label: String, help_text: String)
}

Constructors

  • SubForm(name: String, label: String, help_text: String)

    Arguments

    • name

      The name of the subform. This is used to prefix all the fields of the subform, so it should be unique for each subform added to aform. It is untested with any values other than strings consisting solely of alphanumeric characters and underscores.

    • label

      The label of the subform. This is completely optional, but if the subform is rendered inside a <fieldset> then it is recommended to have a <legend> with this label.

    • help_text

      Help text for the subform. There is less of a standard for this, but again, if rendered in a <fieldset> then area-describedby can be used to point to an element with this help text.

Functions

pub fn set_help_text(sub: SubForm, help_text: String) -> SubForm
pub fn set_label(sub: SubForm, label: String) -> SubForm
pub fn set_name(sub: SubForm, name: String) -> SubForm
pub fn subform(name: String) -> SubForm

Create a subform with the given name. It uses justin.sentence_case to create a label. You can override the label with the set_label function.

subform("address")
|> set_label("Shipping Address")
Search Document