[Catalyst] receiving form-elements in sequence...?

will trillich will.trillich at serensoft.com
Tue Dec 28 17:18:08 GMT 2010


$c->req->body was empty every time we looked at it, so we went with Hernan's
javascript approach... works a treat! Thanks, folks.

<script type=3D"text/javascript">
// Drag-and-drop might reorder things here,
// so we store the ID sequence in hidden "seq" field, then submit:
function do_submit() {
    var x =3D [];
    $("#services .ix").each( function(){
        x.push( $(this).val() );
    });
    x =3D x.join(',');
    $("#services #seq").val( x );
    $("#services").submit();
}
</script>

<form id=3D"services" method=3D"POST">
<input type=3D"*hidden*" id=3D"*seq*" name=3D"*seq*" value=3D""/>
<ul id=3D"sortable">
[% FOREACH row =3D item_rs.all %]
<li>
    <span class=3D"name">
        [% row.name %]
    </span>
    <span style=3D"email">
        <input type=3D"checkbox" name=3D"email.[% row.id %]" value=3D"Email=
"[%
            row.email_trigger ? ' checked=3D"yes"' : ''
            %]/>
    </span>
    <input type=3D"*hidden*" class=3D"*ix*" value=3D"[% row.id %]" />
    <br clear=3D"both"/>
</li>
[% END %]
</ul>
<button type=3D"button" onClick=3D"*do_submit()*">Save Updates</button>
</form>

We're using http://jqueryui.com/demos/sortable to do the drag-and-drop.


On Mon, Dec 27, 2010 at 2:28 PM, Mesdaq, Ali <amesdaq at websense.com> wrote:

> Looks like there is no method to do this from what I can tell but if you
> really needed to do it this way you could probably just de-serialize it
> yourself by looking at the raw content with $c->req->body
> http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.80029/lib/Catalyst/Re=
quest.pm#$req-%3Ebody. But that=92s probably way more work than doing some =
of the suggestions
> mentioned by others like having the position specifically set in the post.
>
>
>
> Thanks,
>
> ------------------------------------------
>
> Ali Mesdaq (CISSP, GIAC-GREM)
>
> Sr. Security Researcher
>
> Websense Security Labs
>
> http://www.WebsenseSecurityLabs.com <http://www.websensesecuritylabs.com/>
>
> ------------------------------------------
>
>
>
> *From:* will trillich [mailto:will.trillich at serensoft.com]
> *Sent:* Monday, December 27, 2010 8:52 AM
> *To:* Catalyst
> *Subject:* [Catalyst] receiving form-elements in sequence...?
>
>
>
> Quick question: how do we determine the sequence of submitted form
> elements?
>
>
>
> Background: we've got several data-rows that we're going to let the user
> reorder via Javascript drag-and-drop. Looking in $c->req->params, being a
> hash, gives us all elements, but no clue as to which item is first, which=
 is
> next, which is last. So in case the opening line above isn't quite the ri=
ght
> question, how do we submit a new sequence of rows via $c->req?
>
>
>
> This is probably a simple one, but we haven't found the
> $c->req->[sequenced-form-items] method yet (gotta be available via
> Catalyst::Request, I hope). Pointers gladly welcomed. Thanks!
>
>
>
> --
> Failure is not important. How you overcome it, is.
> -- Nick Vujicic
>
>
>
> Click here <https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg=3D=3D> =
to
> report this email as spam.
>
>
> Protected by Websense Hosted Email Security =97 www.websense.com
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>


-- =

Failure is not important. How you overcome it, is.
-- Nick Vujicic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101228/f82d5=
fd3/attachment.htm


More information about the Catalyst mailing list