Last active
August 29, 2015 14:11
-
-
Save adamw/5f68795f90b34abf7df1 to your computer and use it in GitHub Desktop.
Supler actions
This file contains hidden or 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 carForm(removeAction: Car => ActionResult[Car]) = form[Car](f => List( | |
f.field(_.make).possibleValues(_ => carMakesAndModels.keys.toList).label("Make"), | |
// etc. | |
// trait Form[T] { def action(T => ActionResult[T]): Row[T] } | |
f.action(removeAction).label("Delete") | |
)) | |
val personForm = form[Person](f => List) | |
f.field(_.firstName).label("label_person_firstname"), | |
// etc. | |
f.subform(_.cars, carForm(f.parentAction((person, index, car) => person.removeCar(index)))) | |
.label("Cars").renderHint(asList()), | |
)) | |
/* | |
f.parentAction może być użyte tylko w f.subform (sprawdzane przy kompilacji) i jest przez makro rejestrowana akcja w SubformFieldzie | |
f.parentAction: ((Person, Int, Car) => ActionResult[Person]) => (Car => ActionResult[Car]) | |
ActionResult jest po to żeby potem "odpalić" wszystkie akcje i odpowiednio pozmieniać pola w parentach itd. | |
(może być wielokrotnie zagnieżdżone) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment