Re: [Lift] SHtml.onSubmit creates unique names for every radio button with the same name

73 views
Skip to first unread message

David Pollak

unread,
Nov 14, 2012, 11:45:29 AM11/14/12
to lif...@googlegroups.com
Sorry for the delay.

Seems like a bug. Please open a ticket.

On Mon, Nov 5, 2012 at 8:24 AM, Jeff May <viralid...@gmail.com> wrote:
At my company, we prefer to keep all of the form text, attributes, and styling in the template, and then use onSubmit to bind a call back. Unfortunately, onSubmit does not work for radio buttons. Here is an example of the snippet code:

  def renderDeactivationForm(in: NodeSeq): NodeSeq = {
    (
      "name=reason" #> SHtml.onSubmit(reason set _)
    )(in) ++ SHtml.hidden(processDeactivation)
  }

And a trimmed down version of the template code:

<div class="lift:DeactivationSnippet.renderDeactivationForm">
    <form id="deativate_form" class="lift:form.ajax">
        <h3>Reason for deactivating: </h3>
        <ul class="choices">
            <li>
                <label>
                    <input type="radio" name="reason"
                           value="This is temporary. I'll be back.">
                    <span>This is temporary. I'll be back.</span>
                </label>
            </li>
            ...
        </ul>
        ...
        <input type="submit" value="Confirm"/>
    </form>
</div>

When I run the page, each radio button has a unique name, so it no longer acts as a radio button. I think this is a bug, since in the onSubmitImpl code, it attempts to handle the situation where a node in the given NodeSeq has the same name as another radio button, however the function receives a NodeSeq containing only one input at a time, so every time it caches the name, it immediately throws it away. Is there a workaround I can use in my selector?

I am able to fix this by using SHtml.radio or adding a hidden element for processing, but this means I have to specify all the attributes in the Lift code. This will work for the time being, but I can see this being an issue elsewhere in our code.

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



--
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net


Reply all
Reply to author
Forward
0 new messages