Styling individual Wizard Fields

71 views
Skip to first unread message

adamc...@gmail.com

unread,
Jun 3, 2011, 3:25:59 PM6/3/11
to Lift
Hello,
First off let me say thank you to the developers for their excellent
work. I'm using liftweb for a client's website and specifically lift-
wizard for a multi-page order form. For various parts of the form I
need to use apply some javascript or css only to specific fields on
the wizard screen. The only way to target fields that I've seen is
uniqueFieldId, but this seems to be generated on every compilation, so
any css/javascript will be broken every time I run my app. How can I
apply an id or class to specific fields (such as password() or
field()) from within the wizard's scala class?
Thanks again,
Adam

David Pollak

unread,
Jun 3, 2011, 4:16:27 PM6/3/11
to lif...@googlegroups.com
please look at FormParam:

field("Name", "", FormParam("class" -> "fruitbat"))




--
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.




--
Lift, the simply functional web framework http://liftweb.net

adamc...@gmail.com

unread,
Jun 6, 2011, 9:07:34 AM6/6/11
to Lift
Perfect! Thanks a lot David.

On Jun 3, 4:16 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> please look at FormParam:
>
> field("Name", "", FormParam("class" -> "fruitbat"))
>
> On Fri, Jun 3, 2011 at 12:25 PM, adamcoim...@gmail.com <
>
>
>
>
>
>
>
>
>
> adamcoim...@gmail.com> wrote:
> > Hello,
> > First off let me say thank you to the developers for their excellent
> > work. I'm using liftweb for a client's website and specifically lift-
> > wizard for a multi-page order form. For various parts of the form I
> > need to use apply some javascript or css only to specific fields on
> > the wizard screen. The only way to target fields that I've seen is
> > uniqueFieldId, but this seems to be generated on every compilation, so
> > any css/javascript will be broken every time I run my app. How can I
> > apply an id or class to specific fields (such as password() or
> > field()) from within the wizard's scala class?
> > Thanks again,
> > Adam
>
> > --
> > 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.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Simply Lifthttp://simply.liftweb.net

adamc...@gmail.com

unread,
Jun 6, 2011, 2:49:23 PM6/6/11
to Lift
Oops, celebrated too soon. Having a strange problem with FormParam:

these three fields show up but have no class attribute:

val register = field(S ? "Save profile?", if (User.loggedIn_?)
true else false, FormParam("class" -> "savebox"))
field("Name", "", FormParam("class" -> "xx"))
if (User.loggedIn_?) field("logged","true",FormParam("class" ->
"logged")) else field("logged","false",FormParam("class" -> "logged"))

these show up with the specified class:

val pwd1 = if (User.loggedIn_?) null else password("Password",
"", FormParam("class" -> "pwd"))
val pwd2 = if (User.loggedIn_?) null else password("Password (re-
enter)", "", mustMatch _ , FormParam("class" -> "pwd"))
select("foo","bar",List("foo","bar"), FormParam("class" -
> "foo"))

Everything compiles successfully and works besides the attribute
creation. It would seem that FormParam is working with everything
except field(). I'm using lift 2.2 against Scala 2.8.1 with sbt 0.7.7
using LiftProject and Scala 2.7.7.
Any ideas would be appreciated.
Thanks again,
Adam

adamc...@gmail.com

unread,
Jun 6, 2011, 4:35:47 PM6/6/11
to Lift
Apologies for the triple post, but I wanted to get this question up
before I left the office today: I'm adding Mapper fields to the wizard
screen using the following method:
addFields(() =>
o.Address2.asInstanceOf[net.liftweb.util.FieldContainer])
Is there a way to apply an id or class attribute to these mapper
fields?

David Pollak

unread,
Jun 6, 2011, 5:15:01 PM6/6/11
to lif...@googlegroups.com
A couple of things... please upgrade to Lift 2.3 or 2.4-M1.  There were significant enhancements to LiftScreen in both.

Also, if you ever type null in your source code are are not interacting with Java libraries, check what you're doing and try a different approach.  null should never make its way into your day-to-day Scala code.

If you want to put together an example (see Posting example code | Lift Space | Assembla ) I can take a look at it and see what I can come up with.


--
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.




--
Lift, the simply functional web framework http://liftweb.net

dave

unread,
Jun 7, 2011, 9:55:46 AM6/7/11
to Lift
On Jun 6, 4:15 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> A couple of things... please upgrade to Lift 2.3 or 2.4-M1.  There were
> significant enhancements to LiftScreen in both.

I recently ran into the same problem with Lift 2.3. I've posted a
sample app in the form-param branch at git://github.com/leedm777/lift-sample-app.git.

git clone git://github.com/leedm777/lift-sample-app.git -b form-param

Thanks!
dave
<><

adamc...@gmail.com

unread,
Jun 7, 2011, 11:25:10 AM6/7/11
to Lift
I've tested FormParam in field() with 2.2 scala 2.8.1, 2.3 scala 2.9.0
and 2.8.1, 2.4-M1 scala 2.9.0 and 2.8.1. Problem seems to be
universal.

David Pollak

unread,
Jun 7, 2011, 4:17:53 PM6/7/11
to lif...@googlegroups.com
On Tue, Jun 7, 2011 at 6:55 AM, dave <leed...@yahoo.com> wrote:
On Jun 6, 4:15 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> A couple of things... please upgrade to Lift 2.3 or 2.4-M1.  There were
> significant enhancements to LiftScreen in both.


Okay... it looks like LiftScreen.field isn't honoring FormParam and there's no simple generic way to add params to MappedField.

Please open a ticket (http://ticket.liftweb.net you must be a watcher of the LiftWeb space on Assembla to open a ticket) referencing this thread and assign the ticket to me for 2.4-M2.  I'll fix field and add a mechanism to MappedField (and Record Field) for adding attributes to the form elements.
 

I recently ran into the same problem with Lift 2.3.  I've posted a
sample app in the form-param branch at git://github.com/leedm777/lift-sample-app.git.

git clone git://github.com/leedm777/lift-sample-app.git -b form-param

Thanks!
dave
<><

--
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.

Reply all
Reply to author
Forward
0 new messages