Merge pull request #1604 from jprider63/optional-labels

Optional labels
This commit is contained in:
Michael Snoyman 2019-06-16 06:28:08 -07:00 committed by GitHub
commit af038b75f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
* Add `.sr-only` to 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>