w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I have a empty number on play forms?

Use the optional(number) constraint:

"ticketNumber" -> optional(number),
"amountEntered" ->  optional(number),
"amountMeasured" -> optional(number),
"leaseID_dpID" -> optional(number),
"customerID" -> optional(number)

Just as number maps to Int, optional(number) maps to Some[Int]. The constraint allows the field to pass validation if no value is submitted in the form, assigning the field the value None. I appreciate however that this will then require you to change the signature of your case class constructor:

case class TransactionFormData(..., ticketNumber:Option[Int],

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.