MangelMaxime / Fable.Form

Home Page:https://mangelmaxime.github.io/Fable.Form/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

There seem to be no way to flag a text field as optional (not required)

zelenij opened this issue · comments

commented

Subject...

I forgot to expose the function for it, it is now available.

See the doc comment, to know more about how to use it:

/// <summary>
/// Make a form be <b>optional</b>
///
/// If the form has values set, it will return <c>Some 'Value</c>.
///
/// Otherwise, it returns <c>None</c>.
/// </summary>
/// <param name="form">Form to make optional</param>
/// <example>
/// <code lang="fsharp">
/// let emailField =
/// Form.emailField
/// {
/// // ...
/// }
///
/// let ageField =
/// Form.numberField
/// {
/// // ...
/// }
///
/// let onSubmit =
/// fun email ageOpt ->
/// LogIn (email, ageOpt)
///
/// Form.succeed onSubmit
/// |> Form.append emailField
/// |> Form.append (Form.optional ageField)
/// </code>
/// </example>
/// <returns>An optional form</returns>

Also, making a form optional returns 'T option