IE8 and single-field forms

20 views
Skip to first unread message

Ryan Donahue

unread,
Aug 6, 2009, 10:39:53 AM8/6/09
to Lift
Apparently if your form has only one text field (input tag w/
type=text) and one button tag, IE8 does not include the button as a
field in the post, but only includes the text field. Here's the IE8
bug report:
https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=389736

The result is that my function that is bound to the button is not
called when processing the post. I've worked around it by adding
another input tag of type=text and style=display:none (hidden field
didn't fix it).

Anyway, just wanted to post a heads up and see if anybody else has
come across this.

The relevant code is below.

Template:

<lift:MemberSnippet.sendConfirmation form="POST">
<fieldset>
<legend>Confirm Email Address</legend>
<p>First, we need to confirm your email address so we know it's
yours.</p>
<label>Email Address:</label><br/><signup:email/><br/>
<signup:submit/>
</fieldset>
</lift:MemberSnippet.sendConfirmation>


Snippet:

//note that my SForm.button is just the same as SHtml.submit but I use
a button instead of input w/ type=submit

def sendConfirmation(xhtml:NodeSeq) : NodeSeq = {

def doConfirm() : Any = {
if (email.is.length > 0) {
try {
MemberSystem.confirmEmailAddress(email.is)
notice("Your confirmation email will be sent in a few
moments.")
hideForms.set(true)
}
catch {
case MemberSystem.InvalidEmailAddressException(msg) =>
error("The email address you provided "+msg)
case MemberSystem.EmailAddressAlreadyInUseException =>
error("The email address you provided is already being
used by another member")
case _ =>
error("We were unable to send to this email address,
please try another")
}
}
else { error ("Email address is required") ; Empty}
}

if (!hideForms.is)
bind("signup", xhtml,
"email" -> FocusOnLoad(SForm.text(email.is, email(_))),
"submit" -> SForm.button("Send Confirmation", doConfirm))
else Nil

}

David Pollak

unread,
Aug 7, 2009, 11:43:06 AM8/7/09
to lif...@googlegroups.com
When you use a Button and it doesn't get included in the POST (either on IE8 or for Ajax forms), use the SHtml.hidden() method to include a hidden field that's included in the server request.
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

Ryan Donahue

unread,
Aug 7, 2009, 5:00:43 PM8/7/09
to Lift
That works perfectly. Thanks.

On Aug 7, 11:43 am, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> When you use a Button and it doesn't get included in the POST (either on IE8
> or for Ajax forms), use the SHtml.hidden() method to include a hidden field
> that's included in the server request.
>
>
>
> On Thu, Aug 6, 2009 at 7:39 AM, Ryan Donahue <donahu...@gmail.com> wrote:
>
> > Apparently if your form has only one text field (input tag w/
> > type=text) and one button tag, IE8 does not include the button as a
> > field in the post, but only includes the text field.  Here's the IE8
> > bug report:
>
> >https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackI...
> Beginning Scalahttp://www.apress.com/book/view/1430219890
Reply all
Reply to author
Forward
0 new messages