forms - 向 Yesod 表单添加样式

标签 forms authentication twitter-bootstrap haskell yesod

我正在尝试使用 Yesod 的身份验证插件:yesod-auth-account。它提供了一个默认的表单来使用,我希望向它添加一些 Bootstrap/模板特定的样式。如果我使用自定义表单,我将必须重写很多方法。

这尤其紧迫,因为我想在不同的显示上下文中重用该表单(在导航栏中、注册表单旁边等)。

有什么想法吗?

最佳答案

您可以包装默认电子邮件AuthPlugin:

authEmailCustom :: YesodAuthEmail m => AuthPlugin m
authEmailCustom =
    AuthPlugin "email" (apDispatch authEmail) $ \tm ->
        [whamlet|
<form method="post" action="@{tm loginR}">
    <input type="email" name="email">
    <input type="password" name="password">
    <input type="submit" value="submit">
    <a href="@{tm registerR}">I don't have an account
|]

只需替换您的样式形式即可。然后使用它代替默认的:

instance YesodAuth App where
    ...
    authPlugins _ = [authEmailCustom]

希望这有帮助。

关于forms - 向 Yesod 表单添加样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18749068/

相关文章:

php - 多个表单访问一个 PHP 页面并进行表单验证

zend-framework - 在 Zend 框架中使用表单

php - Zend Auth 和 ACL

Spring 和条纹安全设计

css - Yii 2 应用程序中缺少 Bootstrap 3 标注

ruby-on-rails - 如何为特色对象预填充表单?

javascript - 使用 Vue、Vuex 和 Firebase 进行 Twitter 身份验证

html - 强制单选按钮显示内联

html - 避免在 Bootstrap 中面板内的行重叠

javascript - 选择下拉表单验证(显示文本)