pedrorijo91 / pedrorijo.com-comments

Repository to hold https://pedrorijo.com/ comments using https://utteranc.es/
0 stars 0 forks source link

blog/advanced-play-forms/ #2

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

Creating forms on your Play application - Part 2

Advanced HTML forms in Play framework.

https://pedrorijo.com/blog/advanced-play-forms/

sake92 commented 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

pedrorijo91 commented 4 years ago

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.

digital-infinity7 commented 3 years ago

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 ?

pedrorijo91 commented 3 years ago

hey @digital-infinity7

If you look at the source code you'll see that simpleForm is created by us

digital-infinity7 commented 3 years ago

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 !

digital-infinity7 commented 3 years ago

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.

pedrorijo91 commented 3 years ago

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!

romaincomeau commented 11 months ago

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.

pedrorijo91 commented 11 months ago

hey @romaincomeau . have you checked https://www.playframework.com/documentation/2.8.x/ScalaCustomFieldConstructors ?

romaincomeau commented 11 months ago

I hadn't, this looks exactly like what I should be using. Thank you sir.