formz_nakai/widgets

Functions

pub fn checkbox_widget() -> fn(Field, Args) -> Node

Create an <input type="checkbox">. The checkbox is checked if the value is “on” (the browser default).

pub fn hidden_widget() -> fn(Field, a) -> Node

Create a <input type="hidden">. This is useful for if a field is just passing data around and you don’t want it to be visible to the user. Like say, the ID of a record being edited.

pub fn input_widget(type_: String) -> fn(Field, Args) -> Node

Generate any <input> like type="text", type="email" or type="url".

pub fn number_widget(
  step_size: String,
) -> fn(Field, Args) -> Node

Create a <input type="number">. Normally browsers only allow whole numbers, unless a decimal step size is provided. The step size here is a string that will be put straight into the step-size attribute. Doing non-whole numbers this way does mean that a user can only input numbers up to the precision of the step size. If you truly need any float, then a type="text" input might be a better choice.

pub fn password_widget() -> fn(Field, Args) -> Node

Create an <input type="password">. This will not output the value in the generated HTML for privacy/security concerns.

pub fn select_widget(
  variants: List(#(String, String)),
) -> fn(Field, Args) -> Node

Create a <select></select> with <option>s for each variant. The list of variants is a two-tuple, where the first item is the text to display and the second item is the value.

pub fn textarea_widget() -> fn(Field, Args) -> Node

Create a <textarea></textarea>.

Search Document