What do you mean by "cannot be edited"? Do you get some kind of exception? What form object do you display to user to edit category? Do you use select, or radio, or anything else?
Please, be more specific.
Jan
>
> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
I do it by writing snippets (more on snippets can be found here: http://simply.liftweb.net/index-3.4.html#toc-Section-3.4) that either use LiftScreen or SHtml to display a form (http://simply.liftweb.net/index-Chapter-4.html#toc-Chapter-4).
I can make some code example if you can put your current code in a runnable state (maven or sbt) on github or some other place.
Jan
There are two files to look at - scala/code/snippet/ProductScreen.scala and webapp/productScreen.html
I've written the code very fast as I have very little time currently, so there might be some bugs, but it should at least give you an idea
import scala.xml._
import net.liftweb.common._
import net.liftweb.mapper._
import net.liftweb.util._
trait MyMapper[OwnerType <: MyMapper[OwnerType]]
extends LongKeyedMapper[OwnerType] with IdPK {
self: OwnerType =>
}
trait MyMetaMapper[A <: MyMapper[A]]
extends LongKeyedMetaMapper[A]
with LongCRUDify[A] {
self: A =>
def primaryKeyDisplayField: BaseOwnedMappedField[A] = null
}
abstract class MyMappedForeignKey[T<:MyMapper[T], O<:MyMapper[O]](theOwner: T, _foreignMeta: => MyMetaMapper[O])
extends MappedLongForeignKey[T, O](theOwner, _foreignMeta) {
override def foreignMeta = _foreignMeta
override def dbIndexed_? = true
override def asHtml = {
<span>{foreignMeta.findByKey(this.get)
.map(_.fieldByName(foreignMeta.primaryKeyDisplayField.name).openOr(Text("Error"))).openOr(Text("ERROR MyMappedForeignKey"))}</span>
}
override def validSelectValues/*: Box[List[(Long, String)]]*/ = {
Full(foreignMeta.findAll(/*OrderBy(foreignMeta.primaryKeyField, Ascending)*/)
.map(i => (i.id.get,
i.fieldByName(foreignMeta.primaryKeyDisplayField.name).openOr(Text("ERROR")).toString())))
}
}
class MyData extends MyMapper[MyData] {
def getSingleton = MyData
object myForeignData extends MyMappedForeignKey(this, MyForeignData)
object name extends MappedString(this, 30)
}
object MyData extends MyData with MyMetaMapper[MyData] { }
class MyForeignData extends MyMapper[MyForeignData] {
def getSingleton = MyForeignData
object name extends MappedString(this, 30)
}
object MyForeignData extends MyForeignData with MyMetaMapper[MyForeignData] {
override def primaryKeyDisplayField = name
}