multiselect bug when clearing selection with initial values

21 views
Skip to first unread message

alexmnyc

unread,
Mar 25, 2015, 8:27:05 PM3/25/15
to lif...@googlegroups.com
Guys,

I keep running into the same issue with the multiselect control. The test is the following:

If multiselect is initialized with selected values, clearing multiselect clientside (nothing i selected) and submitting the form yields initial values that were set rather than an empty List(). Does anyone know how to overcome clearing of the selected values in multiselect?

Thank you,

Alex

alexmnyc

unread,
Mar 25, 2015, 8:34:27 PM3/25/15
to lif...@googlegroups.com
a simple example is 

    lazy val features = Feature.findAll(OrderBy(Features.name, Ascending))
    
val mS = multiselect("Features",
    userVar.is.features.all,
    features){
    feature:Feature => feature.label
  }

in finish() ....  mS equals initially set userVar.is.features.all if all options are cleared in the form

alexmnyc

unread,
Mar 25, 2015, 10:52:28 PM3/25/15
to lif...@googlegroups.com
Forgot to mention this with lift 3.0-M1, Scala 2.10.4

Richard Dallaway

unread,
Mar 26, 2015, 3:16:05 AM3/26/15
to lif...@googlegroups.com
Richard

On Thu, 26 Mar 2015 at 02:52 alexmnyc <a.mik...@gmail.com> wrote:
Forgot to mention this with lift 3.0-M1, Scala 2.10.4

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alexmnyc

unread,
Mar 26, 2015, 12:03:30 PM3/26/15
to lif...@googlegroups.com
Richard, thank you.

Since this was in liftscreen, I had to do the following which is working as expected.

override def multiselect[T](name: => String, default: => Seq[T], choices: => Seq[T], stuff: FilterOrValidate[Seq[T]]*)
(implicit f: SHtml.PairStringPromoter[T]): Field {type ValueType = Seq[T]; type OtherValueType = Seq[T]}
= {
val eAttr = grabParams(stuff)

makeField[Seq[T], Seq[T]](name, default,
field =>
Full(SHtml.hidden( () => field.set(Nil))++
SHtml.multiSelectElem(field.otherValue,
field.is, eAttr: _*)(field.set(_))),
OtherValueInitializerImpl[Seq[T]](() => choices),
stuff: _*)
}
Reply all
Reply to author
Forward
0 new messages