From 297b408e9c9cd1d85c6a47630d4ca45735626041 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 10 May 2023 13:12:49 +0000 Subject: [PATCH] chore(form): disable no-answer option for m/apreq forms --- src/Utils/Form.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Utils/Form.hs b/src/Utils/Form.hs index 1dfdc2703..79a3604b1 100644 --- a/src/Utils/Form.hs +++ b/src/Utils/Form.hs @@ -1667,7 +1667,8 @@ mpreq :: (RenderMessage site (ValueRequired site), HandlerSite m ~ site, MonadHa -- ^ Pseudo required -- -- `FieldView` has `fvRequired` set to `True` and @FormSuccess Nothing@ is cast to `FormFailure`. --- Otherwise acts exactly like `mopt`. +-- Otherwise acts exactly like `mopt` without a default value and like `mreq` with a given default value +mpreq f fs mx@(Just _) = mreq f fs mx -- This shortcut hides the invalid no-answer option if a default is provided mpreq f fs@FieldSettings{..} mx = do mr <- getMessageRender (res, fv') <- mpreq' f fs $ Just <$> mx