Skip to content

Commit

Permalink
Fix form element in MongoListField
Browse files Browse the repository at this point in the history
  • Loading branch information
eltimn committed May 19, 2014
1 parent 6646e7a commit e1e08bb
Showing 1 changed file with 15 additions and 13 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2013 WorldWide Conferencing, LLC
* Copyright 2010-2014 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -87,20 +87,22 @@ class MongoListField[OwnerType <: BsonRecord[OwnerType], ListType: Manifest](rec
/** Options for select list **/
def options: List[(ListType, String)] = Nil

private def elem = SHtml.multiSelectObj[ListType](
options,
value,
set(_)
) % ("tabindex" -> tabIndex.toString)
private def elem = {
def elem0 = SHtml.multiSelectObj[ListType](
options,
value,
set(_)
) % ("tabindex" -> tabIndex.toString)

SHtml.hidden(() => set(Nil)) ++ (uniqueFieldId match {
case Full(id) => (elem0 % ("id" -> id))
case _ => elem0
})
}

def toForm: Box[NodeSeq] =
if (options.length > 0)
uniqueFieldId match {
case Full(id) => Full(elem % ("id" -> id))
case _ => Full(elem)
}
else
Empty
if (options.length > 0) Full(elem)
else Empty

def asJValue = JArray(value.map(li => li.asInstanceOf[AnyRef] match {
case x if primitive_?(x.getClass) => primitive2jvalue(x)
Expand Down

0 comments on commit e1e08bb

Please sign in to comment.