Hey all,
I'm getting stuck on some basics and I thought rather than spend more
time looking through code and playing the trial and error game, I'll
ask for clarification. I'm positive that what I'm doing is *not* best
practice. :) I'll put anything that comes from this on the wiki as
well.
1) SImply spilling the contents of a model object as read only - is
there a better way than binding each of the members, something like a
read-only toForm? I looked at asHtml, but it appears to be for a
single member, not an object.
2) toForm is great for many cases, but if I would like to offer a
<select> that has a list of all the ForeignKeyed members, then I'm not
sure how to build the form, as toForm does not magically create the
<select> for me.
For example, I have a Client Model object and a Project Model object.
One of the fields in Project is a foreign key to Client. toForm will
create an input field for the ClientID foreign key, but I want a
<select>.
I'm using the sites/example as my basis for my project, so most of my
code spelunking is from that app.
Thanks,
Tyler
--
lift, the secure, simple, powerful web framework http://liftweb.net
Collaborative Task Management http://much4.us
If you return empty, then there's nothing to display and you get the
"Can't Change" element.
If you want to return a list, you would do something like:
override def validSelectValues: Can[List[(Long, String)]] = Full
(Clients.findAll.map(c => (c.id.is, c.name.is)))
Thanks,
David
--
David Pollak
http://blog.lostlake.org
A followup:
Now that this is working well, I'd like to automatically set the
correct User, right now I'm doing this, crazy or sane?
object userID extends MappedLongForeignKey(this, User){Full(User.findAll(By(User.id, User.currentUser.openOr(new
override def validSelectValues: Can[List[(Long, String)]] =
User).id)).map(c => ( c.id.is, c.firstName + " " + c.lastName.is)))
}
It's working, but is it right?
Thanks,
Tyler
On Jan 1, 1:26pm, TylerWeir <tyler.w...@gmail.com> wrote:
> Gah, ok, I was being a bonehead.
>
> Thanks... again. :)
>
> Ty
>
> David Pollak wrote:
> > Tyler,
>
> > If you return empty, then there's nothing to display and you get the
> > "Can't Change" element.
>
> > If you want to return a list, you would do something like:
> > override def validSelectValues: Can[List[(Long, String)]] = Full
I want the list to only contain the logged in user, otherwise the logged in user can create a record for a different user.
always prefacing statements with log4j categories,
Steve