Ok I think I got it: trait CustomMappedField[F, T <: Mapper[T]] extends MappedField[F, T] { override def fieldId = uniqueFieldId.toOption.map(Text(_)) }
object description extends MappedString(this, 100) with CustomMappedField[String, Expense] It works but I still don't like the fact that I need to write CustomMappedField[String, Expense] while it's already known that the description object inherits from MappedField[String, Expense]. There should be something more elegant. On Mon, Nov 23, 2009 at 1:11 AM, Oscar Picasso <oscarpica...@gmail.com>wrote: > Hi, > > The out of the box form generated by a Mapper looks like that: > > <form action="/expense/edit" method="post"> >> <table> >> ... >> <tr> >> <td>description</td> >> <td><input name="F3167038127803C0" type="text" maxlength="100" >> value="" /></td> >> </tr> >> ... >> <tr> >> <td> </td> >> <td><input value="Create" type="submit" /></td> >> </tr> >> </table> >> </form> >> > > I would like however something like that: > > <form action="/expense/edit" method="post"> >> <table> >> ... >> <tr> >> <td><label for="expense_description">Expense >> Description</label></td> <!-- The localized label --> >> <td><input id="expense_description" name="F3167038127803C0" >> type="text" maxlength="100" value="" /></td> >> </tr> >> ... >> <tr> >> <td> </td> >> <td><input value="Create" type="submit" /></td> >> </tr> >> </table> >> </form> >> > > As an exercise I just tried to add the id attribute to the field element: > >> object description extends MappedString(this, 100) { >> override def fieldId = uniqueFieldId.toOption.map(Text(_)) >> } >> > > However I want to do this kind of customization to all the fields without > overriding the fieldId method in each of them. > I thought about writing a mixin trait with the fieldId method and having > all my fields extends this mixin. > > Is this the right approach? If so does this mixin trait needs to extends > MappedField and what should be its signature? > These are some basic questions, but I have not programmed in scala since > quite a long time so I am a little confused about the right approach. > > Or maybe there is a better idea than using a mixin? > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=.