Skip to content

Commit

Permalink
feat: add Form.disableIf
Browse files Browse the repository at this point in the history
[Fable.Form][Fable.Form.Simple.Bulma]

Fix #45
  • Loading branch information
MangelMaxime committed Sep 9, 2024
1 parent 18d4424 commit 28337d9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/Fable.Form.Simple.Bulma/Form.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ module Form =

Base.disable form

/// <summary>
/// Disable a form based on a condition
/// </summary>
/// <param name="condition">The condition to check</param>
/// <param name="form">The form to disable</param>
/// <returns>A new form which has been marked as disabled if the condition is <c>true</c></returns>
let disableIf (condition: bool) (form: Form<'Values, 'A>) : Form<'Values, 'A> =
Base.disableIf condition form

/// <summary>
/// Fill a form <c>andThen</c> fill another one.
///
Expand Down
16 changes: 16 additions & 0 deletions packages/Fable.Form/Base.fs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,22 @@ let disable (form: Form<'Values, 'Output, 'Field>) : Form<'Values, 'Output, 'Fie
}
)

/// <summary>
/// Disable a form based on a condition
/// </summary>
/// <param name="condition">The condition to check</param>
/// <param name="form">The form to disable</param>
/// <returns>A new form which has been marked as disabled if the condition is <c>true</c></returns>
let disableIf
(condition: bool)
(form: Form<'Values, 'Output, 'Field>)
: Form<'Values, 'Output, 'Field>
=
if condition then
disable form
else
form

/// <summary>
/// Transform the 'output' of a form
///
Expand Down

0 comments on commit 28337d9

Please sign in to comment.