I am building a Form to capture several non-zero numbers as inputs. The basic code is:
Ratesform =
FormFunction[{"DriftRates", ""} -> RepeatingElement[
<|"Interpreter" -> Interpreter["Number",
Function[x, x != 0]],
"Hint" -> "Non-zero values only",
"Label" :> "Drift rate " <> ToString[i]|>, {{i, 2}, {1, 10}}],
AppearanceRules -> <|"Title" -> "Enter the possible drift rates",
"SubmitLabel" -> "Submit"|>][];
This produces a form that only accepts non-zero values. But, if the user does enter a 0, it provides the Help "Enter a valid value." I want to override that to read "Enter a non-zero value".
Given the value 0, the Interpreter returns a Failure Object with Message: "Enter a valid value.", Tag: ConditionFailure Input: 0 Type: Number
So I figured adding a Failure option to the Interpreter would do the trick:
Ratesform =
FormFunction[{"DriftRates", ""} -> RepeatingElement[
<|"Interpreter" -> Interpreter["Number",
Function[x, x != 0],
Failure["ConditionFailure",
<|"MessageTemplate"-> StringTemplate["Enter a non-zero number"]|>]],
"Hint" -> "Non-zero values only",
"Label" :> "Drift rate " <> ToString[i]|>, {{i, 2}, {1, 10}}],
AppearanceRules -> <|"Title" -> "Enter the possible drift rates",
"SubmitLabel" -> "Submit"|>][];
But that provides no help at all. How to override the default Failure?