[jifty-devel] passing in args to page regions which include forms

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Tue Jul 10 10:57:29 EDT 2007


Perhaps we're trying to answer the wrong question.

There should be a pretty easy solution to this using regions, it's
part of their purpose. What you really want to do is add a new child
to the end of the list in the "child-list" region when you create a
new one from the "child-add" region. I just added a recipe to the
cookbook covering that a few days ago.

if you place the "child-add" region inside of "child-list" and add a
<div class="list"> wrapping the list of children, you can do this:

<%
         Jifty->web->form->submit(
             label   => 'Submit',
             onclick => [
                 { submit       => $action },
                 { refresh_self => 1 },
                 {   element =>
                         Jifty->web->current_region->parent->get_element(
                         'div.list'),
                     append => $self->fragment_for('view'),
                     args   => {
                         id => { result_of => $action, name => 'id' },
                     },
                 },
             ]
         )
%>

You don't need to pass $parent again because it will remain the same,
but you could pass it if you want.

See Jifty::Manual::Cookbook from the trunk of SVN for the recipe.

On 7/10/07, Matthew Lenz <matthew at nocturnal.org> wrote:
> On Tue, 2007-07-10 at 08:57 -0500, Andrew Sterling Hanenkamp wrote:
> > Believe it. Every action parameter to an action is encoded like this:
> >
> > J:A:F-parent-auto-85bdf599148e8e96c00c26dfc4cb6724-1-S572764
> >
> > This way action parameters can be processed automatically, linked with
> > the submitted action or ignored for a non-submitted action, etc. Your
> > templates want a parameter named:
> >
> > parent
>
> so there is no way without using the dispatcher to pass an argument from
> one template to another directly? i've got other page regions that
> receive the exact same parameter (by building a link()) which is used to
> limit() a collection and that works without a hitch.
>
> > So you need to set that somehow. The usual way is to load whatever you
> > need (possibly using the result of the action) and add:
>
> so i wont need <%args> and <%init> blocks in my templates just move all
> that functionality into the dispatcher?
>
> > set parent => $parent;
> >
> > in your dispatcher.
>
> i'll give it another go.  i'm about ready to propose (and pay out) a
> bounty on a realistic tutorial.
>
> > On 7/9/07, Matthew Lenz <matthew at nocturnal.org> wrote:
> > > On Sun, 2007-07-08 at 15:19 -0400, Nelson Elhage wrote:
> > > > > Still looking for a solution to the following problem.  Nelson's
> > > > > suggestion works partially but I still get an error when it tries to
> > > > > reload.  I have other forms that work fine where all the information is
> > > > > specified in the form.  This seems to be directly linked to needing to
> > > > > insert the fk from a param value.  full code examples of the action are
> > > > > in my original post.
> > > > >
> > > > > [elided]
> > > > > > This works partially but dies upon upon submit.  reloading the server
> > > > > > shows that the data was added to the db properly though.  Here is the
> > > > > > error:
> > > > > >
> > > > > > FATAL - view class error: no value sent for required parameter 'parent'
> > > > > > Stack:
> > > > > >   [/usr/local/share/perl/5.8.8/auto/Jifty/web/templates/autohandler:10]
> > > > > >
> > > > > > FATAL - view class error: ABORT
> > > > > > at /usr/local/share/perl/5.8.8/Jifty/Dispatcher.pm line 748.
> > > > > >
> > > >
> > > > This looks to me like you're trying to show a template that expects a
> > > > C<parent> argument in its C<< <%ARGS> >> section, but you're not giving
> > > > it one, by using C<< set parent => ... >> in the dispatcher.
> > > >
> > > > The arguments to actions and to templates are completely different
> > > > namespaces and have no direct relation to each other -- neither will
> > > > cause the other to autopopulate; It's your job in the dispatcher and
> > > > template to make sure things get routed to each appropriately.
> > > >
> > > > Hope this helps,
> > > >
> > > > - Nelson
> > >
> > > http://lists.bestpractical.com/pipermail/jifty-devel/2007-July/001515.html
> > >
> > > my original post contains exactly what I'm trying to do.  I just can't
> > > believe that Jifty would be designed to make someone jump through that
> > > many hoops.  I have to use the dispatcher just to pass around id's that
> > > I would like to use as hidden form elements?  Is the issue that I'm
> > > trying to do so using a page region/fragment?  Shouldn't I be able to do
> > > all this stuff just using mason templates?  You can do just about
> > > anything in the <init> block that you can do in the dispatcher right?
> > > The tutorial is incredibly misleading if that isn't the case.
> > >
> > > > _______________________________________________
> > > > jifty-devel mailing list
> > > > jifty-devel at lists.jifty.org
> > > > http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
> > >
> > > _______________________________________________
> > > jifty-devel mailing list
> > > jifty-devel at lists.jifty.org
> > > http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
> > >
> > _______________________________________________
> > jifty-devel mailing list
> > jifty-devel at lists.jifty.org
> > http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>


More information about the jifty-devel mailing list