This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputText("validationExample", "messages", required() ++ isNumber) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputText("validationExample", "messages", firstOnly(required(), isNumber)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section( | |
messages = "sectionText", // the name of properties bundle containing section-level text | |
nestingCheckboxes( | |
"myCheckboxes", // the unique name of our widget | |
"questionWording", // the name of the properties bundle containing text for the widget | |
required, // constraints applied to the widget | |
"contactMethods", // the name of the properties bundle containing the key and labels for each checkbox choice | |
Map( // our nested widgets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EMAIL=Email | |
PHONE=Phone | |
TEXT=Text message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nestedInput[M <: Messages[M]](name: String, ...)(...) = | |
Input(name, ..., layoutTemplateName = "nestedWidgetBoilerplate.mustache", ...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#choices}} | |
<div class="multiple-choice"> | |
<input id="{{id}}_{{value}}" name="{{name}}" type="checkbox" value="{{value}}" {{#selected}} checked="checked" {{/selected}} /> | |
<label for="{{id}}_{{value}}">{{{text}}}</label> | |
</div> | |
{{{nestedWidget}}} <!-- addition to output the html of the already-rendered nested widget --> | |
{{/choices}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class NestingCheckboxes[C <: Messages[C]](... nestedWidgets: Map[String, Widget]) extends NestingMultipleChoice[C] { | |
override val nestingMultipleChoiceWidget = new Checkbox(...) { | |
override def render(form: Form, errors: ValidationErrors, requestInfo: RequestInfo)(...): Future[String] = { | |
... | |
// pass result of templateChoices(form, errors, requestInfo) to my template and return the rendered result | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class NestingCheckboxes[C <: Messages[C]](... nestedWidgets: Map[String, Widget]) extends NestingMultipleChoice[C] { | |
override val nestingMultipleChoiceWidget = new Checkbox(...) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait NestingMultipleChoice[C <: Messages[C]] extends WidgetGroup { | |
def nestedWidgets: Map[String, Widget] | |
def nestingMultipleChoiceWidget: MultipleChoice[C] | |
override lazy val widgets: Seq[Widget] = nestingMultpleChoiceWidget +: nestedWidgets.values.toSeq | |
def templateChoices(form: Form, errors: ValidationErrors, requestInfo: RequestInfo)(...): Future[List[Map[String, Any]]] = { | |
nestingMultipleChoiceWidget.choicesForTemplate.map(... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait NestingMultipleChoice[C <: Messages[C]] extends WidgetGroup { | |
def nestedWidgets: Map[String, Widget] | |
def nestingMultipleChoiceWidget: MultipleChoice[C] | |
override lazy val widgets: Seq[Widget] = nestingMultpleChoiceWidget +: nestedWidgets.values.toSeq | |
def templateChoices(form: Form, errors: ValidationErrors, requestInfo: RequestInfo)(...): Future[List[Map[String, Any]]] = { | |
nestingMultipleChoiceWidget.choicesForTemplate.map(... |
NewerOlder