"<lift:snippet type=""Foo.bar""> != <lift:Foo.bar>" #17

Closed
tjweir opened this Issue May 16, 2009 · 4 comments

Projects

None yet

3 participants

@tjweir
Member
tjweir commented May 16, 2009

"<lift:snippet type=""Foo.bar""> != lift:Foo.bar"

Lighthouse #21: http://liftweb.lighthouseapp.com/projects/26102/tickets/21

Member
tjweir commented May 16, 2009

When using <lift:SiteOps.add form="post"> in the template shown below, the form is not being populated after a failed validation. With <lift:snippet type="SiteOps.add" form="post">, it is.

Model:

class Site extends LongKeyedMapper[Site] with IdPK {
def getSingleton = Site

object name extends MappedPoliteString(this, 256) {
override def validations = valMinLen(5, "Name must be at least 5 characters long") _ :: super.validations
}
object abbreviation extends MappedPoliteString(this, 128) {
override def validations = valMinLen(2, "Abbreviation must be at least 2 characters long") _ :: super.validations
}
}

object Site extends Site with LongKeyedMetaMapper[Site] {
override def dbTableName = "sites"
override def fieldOrder = List(name, abbreviation)
}
Template:

<lift:surround with="default" at="content">

New Site

<lift:SiteOps.add form="post">















Name: site:nameA site/site:name
Abbreviation / Short Name: site:abbreviationSite/site:abbreviation
site:submitSubmit/site:submit

/lift:SiteOps.add
/lift:surround
Snippet:

class SiteOps {
def add(form: NodeSeq) = {
val invokedAs = S.invokedAs
val site = Site.create

def newSite(form: NodeSeq): NodeSeq = {
  def saveMe(): Unit = {
    site.validate match {
      case Nil => site.save ; S.notice("Added " + site.name); S.redirectTo("/sites/")
      case xs => S.error(xs) ; S.mapSnippet(invokedAs, newSite)
    }
  }

  bind("site", form,
       "name" -> site.name.toForm,
       "abbreviation" -> site.abbreviation.toForm,
       "submit" -> SHtml.submit("New", saveMe))
}

newSite(form)

}
}

Owner
dpp commented May 21, 2009

Correct capturing of snippet names... closed by ed76af69ea2d04be956977ab6499bb1c6f060af7

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment