Created
June 12, 2018 12:54
-
-
Save mgladdish/f25a55adc5a5270dd3188db48b9a5414 to your computer and use it in GitHub Desktop.
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(... | |
// Iterate through the choices already coverted to template params | |
// For each choice, find the associated nestedWidget by its key | |
// If there is an associated widget, add the result of calling nestedWidget.render(form, errors, requestInfo) to the template params | |
... | |
) | |
} | |
override def render(form: Form, errors: ValidationErrors, requestInfo: RequestInfo)(...): Future[String] = | |
nestingMultipleChoiceWidget.render(form, errors, requestInfo) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment