pub struct Form { /* private fields */ }
Expand description

A HTML form. You can create a form with Form::new() or Form::default() (they are identical) and then use any of the provided methods to manipulate it (for example adding child elements or attributes).

malvolio::prelude::Form::new()
.attribute(Method::Post)
.child(
    Input::default()
        .attribute(Type::Text)
        .attribute(Placeholder::new("Username"))
        .attribute(Name::new("username")),
)
.child(Br)
.child(
    Input::new()
        .attribute(Type::Email)
        .attribute(Placeholder::new("Email"))
        .attribute(Name::new("email")),
)
.child(Br)
.child(
    Input::new()
        .attribute(Type::Password)
        .attribute(Placeholder::new("Password"))
        .attribute(Name::new("password")),
)
.child(Br)
.child(
    Input::new()
        .attribute(Type::Password)
        .attribute(Placeholder::new("Password confirmation"))
        .attribute(Name::new("password_confirmation")),
)
.child(Br)
.child(
    Input::new()
        .attribute(Type::Submit)
        .attribute(Value::new("Login!")),
);

Implementations

Creates a new Form tag.

Add a number of children to a form. This method accepts a single argument which must implement IntoIterator (so for example a Vec) where the item of the iterator implements Into<BodyNode> (any of the types in this crate which you would expect to go in the body of an HTML document should implement this).

Form::new().children(vec![1, 2, 3].into_iter().map(|item| {
    Label::new(format!("Item number: {}", item))
}));

Add a single child to a form. This method accepts a single item implementing Into<BodyNode>.

Form::new()
    .child(Label::new("Some input"))
    .child(Input::new().attribute(Name::new("some-input")));

Add an attribute to the current form. This accepts any item implementing Into<FormAttr> (which is all the members of the FormAttr enum).

Form::new()
    .attribute(Method::Post)
    .attribute(Action::new("/"));

Read an attribute that has been set

Attach a new H1 instance to this class. Note that this method only allows you to provide text, and no additional attributes. If you want to specify extra attributes, you should instead use the “child” method (see the documentation of that method for more details).

Body::new().h1("Hello World!");

This is just a convenience wrapper, and is functionally equivalent to calling the child method (but somewhat more concise).

Body::new().child(H1::new("Hello World!"));

Attach a new H2 instance to this class. Note that this method only allows you to provide text, and no additional attributes. If you want to specify extra attributes, you should instead use the “child” method (see the documentation of that method for more details).

Body::new().h2("Hello World!");

This is just a convenience wrapper, and is functionally equivalent to calling the child method (but somewhat more concise).

Body::new().child(H2::new("Hello World!"));

Attach a new H3 instance to this class. Note that this method only allows you to provide text, and no additional attributes. If you want to specify extra attributes, you should instead use the “child” method (see the documentation of that method for more details).

Body::new().h3("Hello World!");

This is just a convenience wrapper, and is functionally equivalent to calling the child method (but somewhat more concise).

Body::new().child(H3::new("Hello World!"));

Attach a new H4 instance to this class. Note that this method only allows you to provide text, and no additional attributes. If you want to specify extra attributes, you should instead use the “child” method (see the documentation of that method for more details).

Body::new().h4("Hello World!");

This is just a convenience wrapper, and is functionally equivalent to calling the child method (but somewhat more concise).

Body::new().child(H4::new("Hello World!"));

Attach a new H5 instance to this class. Note that this method only allows you to provide text, and no additional attributes. If you want to specify extra attributes, you should instead use the “child” method (see the documentation of that method for more details).

Body::new().h5("Hello World!");

This is just a convenience wrapper, and is functionally equivalent to calling the child method (but somewhat more concise).

Body::new().child(H6::new("Hello World!"));

Attach a new H6 instance to this class. Note that this method only allows you to provide text, and no additional attributes. If you want to specify extra attributes, you should instead use the “child” method (see the documentation of that method for more details).

Body::new().h6("Hello World!");

This is just a convenience wrapper, and is functionally equivalent to calling the child method (but somewhat more concise).

Body::new().child(H6::new("Hello World!"));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.