Hello everyone,
I am currently using the Mapper framework to create a very complex
data storage system. In this system, I have the need of changing one
or more MappedFields depending on another MappedField, for example:
trait NonUserEditable
object MyMapper extends LongKeyedMetaMapper[MyMapper] with CRUDify
class MyMapper extends LongKeyedMapper[MyMapper] with IdPK {
def getSingleton = MyMapper
object field1 extends MappedString(this, 64) with LifecycleCallbacks
{
override def beforeValidationOnUpdate {field2(is.capitalize);
super.beforeValidationOnUpdate}
}
object field2 extends MappedString(this, 64) with NonUserEditable
}
I am now looking for the most elegant way to do this; I need
validations on both fields above (which the above code doesn't allow),
and I would like to use CRUDify as much as possible (which might be
overkill but who knows).
So, the goal is to allow for the following process :
1. The user submits a form containing data for field1 through CRUDify
(→ done)
2. The data is stored in field1 by crudDoForm (→ done)
3. field1 is validated, but not field2 (→ How would I do this? Do I
need to rewrite crudDoForm? Because now all fields are validated in
one go, without filtering)
4. Some custom action in field1 is invoked that changes field2 (→ I
can do this with afterValidationOnUpdate if the above point succeeds,
but not otherwise)
5. field2 is changed (→ done, in the custom action)
6. field2 is validated (→ done)
7. Any errors from validations are displayed to the user (→ Can this
be done? Specifically, can I validate field2 in the same cycle as
field1?)
I have hacked CRUDify with a NonUserEditable trait as demonstrated
above (but my hacks are not ;) ) so that CRUDify doesn't include some
fields in its "create" form (dbIncludeInForm_? is BROKEN; the CRUD
"list" doesn't display the hidden field when overriding
dbIncludeInForm_?), so think of the field2 as completely hidden to the
user in the create form. The only problems remaining are the ones
listed above.
Any suggestions on how to solve this would be greatly appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---