Hide bootstrap labels when empty

This commit is contained in:
James Parker 2019-06-10 09:58:05 -04:00
parent c90c50911c
commit 4424abe449
3 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# ChangeLog for yesod-form # ChangeLog for yesod-form
## 1.6.5
* Omit labels in `renderBootstrap3` when they are null.
## 1.6.4 ## 1.6.4
* Make FormResult an instance of Eq * Make FormResult an instance of Eq

View File

@ -32,6 +32,7 @@ import Control.Arrow (second)
import Control.Monad (liftM) import Control.Monad (liftM)
import Data.Text (Text) import Data.Text (Text)
import Data.String (IsString(..)) import Data.String (IsString(..))
import qualified Text.Blaze.Internal as Blaze
import Yesod.Core import Yesod.Core
import Yesod.Form.Types import Yesod.Form.Types
import Yesod.Form.Functions import Yesod.Form.Functions
@ -154,7 +155,7 @@ renderBootstrap3 formLayout aform fragment = do
$case formLayout $case formLayout
$of BootstrapBasicForm $of BootstrapBasicForm
$if fvId view /= bootstrapSubmitId $if fvId view /= bootstrapSubmitId
<label for=#{fvId view}>#{fvLabel view} <label :Blaze.null (fvLabel view):.sr-only for=#{fvId view}>#{fvLabel view}
^{fvInput view} ^{fvInput view}
^{helpWidget view} ^{helpWidget view}
$of BootstrapInlineForm $of BootstrapInlineForm
@ -164,7 +165,7 @@ renderBootstrap3 formLayout aform fragment = do
^{helpWidget view} ^{helpWidget view}
$of BootstrapHorizontalForm labelOffset labelSize inputOffset inputSize $of BootstrapHorizontalForm labelOffset labelSize inputOffset inputSize
$if fvId view /= bootstrapSubmitId $if fvId view /= bootstrapSubmitId
<label .control-label .#{toOffset labelOffset} .#{toColumn labelSize} for=#{fvId view}>#{fvLabel view} <label :Blaze.null (fvLabel view):.sr-only .control-label .#{toOffset labelOffset} .#{toColumn labelSize} for=#{fvId view}>#{fvLabel view}
<div .#{toOffset inputOffset} .#{toColumn inputSize}> <div .#{toOffset inputOffset} .#{toColumn inputSize}>
^{fvInput view} ^{fvInput view}
^{helpWidget view} ^{helpWidget view}

View File

@ -1,5 +1,5 @@
name: yesod-form name: yesod-form
version: 1.6.4 version: 1.6.5
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>