0

docsに従って、ローカライズされたデータ バインディングを使用できます。しかし、これはgrails 4では機能しません。

コントローラ

import grails.databinding.BindingFormat

class TestController {

  def index() {
    render view: 'index'
  }

  def test(DateCommand command) {
    render "${params} <br/><br/> - ${command.errors?.collect { error -> error as String }?.join(', ')}"
  }
}

class DateCommand {

  @BindingFormat(code = 'date.field.format')
  Date aDate
  @BindingFormat('dd/MM/yyyy')
  Date bDate

  static constraints = {
    aDate(nullable: false)
    bDate(nullable: false)
  }
}

インデックス ビュー

<g:form action="test">
  <input type="text" name="aDate" value="27/04/2019" />
  <input type="text" name="bDate" value="27/04/2019" />
  <g:submitButton class="btn btn-success" name="OK" />
</g:form>

メッセージのプロパティ

date.field.format=dd/MM/yyyy

同じコードが grails 3.xx で正常に動作しています

設定が足りないのでしょうか、それともコードに何か問題がありますか?

4

2 に答える 2