Open utterances-bot opened 4 years ago
What do you think about using Scalatags? :) You can rely on your IDE, autocomplete, more typesafety etc. https://github.com/sake92/play-hepek-example/blob/master/app/views/ContactFormView.scala#L37
I'm certainly a fan of having more typesafety @sake92 :) I never explored scalatags, but for bigger projects may help increasing the maintainability of the codebase. Scala.js is other alternative that I've heard very good from the community.
Still, I wonder if any big enough project won't end needing a richer frontend and will simple move to use frontend libs like vue.js, react, angular, etc.
No simpleForm
controller method definition . I assume it is actually forms
.
I have problems with this example (probably wrong version). Which PlayFramework version this example references ?
hey @digital-infinity7
If you look at the source code you'll see that simpleForm is created by us
yeah, thanks. I had just noticed that there is a typo in the source code block in the text above. There is exactly the same method forms
in code block instead of simpleForm
which is referenced by next paragraph.
Nevertheless thanks for a splendid introduction to PF forms !
Once again: on the code block above you have: method forms()
class BasicController @Inject()(cc: ControllerComponents) extends AbstractController(cc) with play.api.i18n.I18nSupport {
def forms() = Action { implicit request: Request[AnyContent] =>
Ok(views.html.basicForm(BasicForm.form))
}
}
In the source code you have method simpleForm()
.
Please correct it.
Thanks again.
thanks for noticing @digital-infinity7 . I didn't have the time to fix it yet (crazy weeks lately). If you are interested feel free to submit a PR updating the typo here: https://github.com/pedrorijo91/pedrorijo91.github.io/blob/master/_posts/2018-02-20-advanced-play-forms.markdown
otherwise I will try to find some time next week
thank you once again!
In regards to this section:
@form(action = routes.BasicController.simpleFormPost()) {
@inputText(userForm("name"),
'_label -> "Custom label",
Are you aware if there is any option to specify the label css? I'm bootstrapping an application and I find that the Form API blocks me in that I have to choose between styling, and functionality.
hey @romaincomeau . have you checked https://www.playframework.com/documentation/2.8.x/ScalaCustomFieldConstructors ?
I hadn't, this looks exactly like what I should be using. Thank you sir.
Creating forms on your Play application - Part 2
Advanced HTML forms in Play framework.
https://pedrorijo.com/blog/advanced-play-forms/