tagfield makes errors on empty tag list

This commit is contained in:
nek0 2014-09-14 05:04:13 +02:00
parent 57610a8b99
commit 7d8d41c6de

View file

@ -82,7 +82,9 @@ generateSalt = (B.pack . take 8 . randoms) <$> getStdGen
tagField = Field tagField = Field
{ fieldParse = \rawVals _ -> do { fieldParse = \rawVals _ -> do
case rawVals of case rawVals of
[x] -> return $ Right $ Just $ T.splitOn " " x [x] -> case null [x] of
False -> return $ Right $ Just $ T.splitOn " " x
True -> return $ Right $ Nothing
_ -> return $ Left $ error "unexpected tag list" _ -> return $ Left $ error "unexpected tag list"
, fieldView = \idAttr nameAttr val eResult isReq -> , fieldView = \idAttr nameAttr val eResult isReq ->
[whamlet|<input id=#{idAttr} type="text" name=#{nameAttr} value=#{either id (T.intercalate " ") eResult}>|] [whamlet|<input id=#{idAttr} type="text" name=#{nameAttr} value=#{either id (T.intercalate " ") eResult}>|]