Return to referring page

46 views
Skip to first unread message

Bob Sleys

unread,
Mar 3, 2012, 2:23:37 PM3/3/12
to hobo...@googlegroups.com
Is there a simple way to make a form return to the referring page on a save or cancel?  I have links to edit an item from 2 different locations in my app and I'd like the user returned to the page that they used to get to edit the item instead of a fixed page.

Bob

Scorpio

unread,
Mar 4, 2012, 9:00:53 AM3/4/12
to Hobo Users
I have not tried it myself but you could try the request referrer
attribute. If it changes to the edit page link upon clicking the edit
(that's the "i'm not sure part") you can always store the referrer as
someone enters the page and purge it upon save/cancel. the choice
between cookie/session/db store is really dependent on your setup and
personal preference.

I'd be glad to try help out more when you supply the details and code
snippets

Bryan Larsen

unread,
Mar 4, 2012, 10:30:24 AM3/4/12
to hobo...@googlegroups.com
http://cookbook-1.3.hobocentral.net/api_tag_defs/after-submit for the
submit button.

For the cancel button, it can be parameterized just like any other
link. As scorpio suggested, you could use the referrer as the href
for it.

Bryan

> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/tXLi-dYNrNgJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

Bob Sleys

unread,
Mar 7, 2012, 9:58:28 PM3/7/12
to hobo...@googlegroups.com
I'm sure I'm doing something dumb again, when isn't that the case.  

Here is my form dryml but the hidden field for the after submit isn't part of the html and of course I always go back to the standard item page.

<extend tag="form" for="LocationMaterial">
<old-form merge  >
<after-submit: go-back/>
<field-list: fields="material, abated, condition, potential, friable, percent_damage, accessible, quantity, unit, notes, locmathists">
<material-view:>
<select-one-or-new-dialog>
<field-list: fields="name"/>
</select-one-or-new-dialog>
</material-view:>
<unit-view:>
<select-one-or-new-dialog/>
</unit-view:>
<locmathists-view:>
<input-many>
<field-list fields='project, date, field_tech'/>
</input-many>
</locmathists-view:>
</field-list:>
<actions:>
<submit label="#{ht 'location_material.actions.save', :default=>['Save']}" param/>
<or-cancel:location param="cancel"/>
</actions:>

</old-form>
</extend>

Bob



On Sunday, March 4, 2012 10:30:24 AM UTC-5, Bryan Larsen wrote:
http://cookbook-1.3.hobocentral.net/api_tag_defs/after-submit for the
submit button.

For the cancel button, it can be parameterized just like any other
link.   As scorpio suggested, you could use the referrer as the href
for it.

Bryan


On Sat, Mar 3, 2012 at 2:23 PM, Bob Sleys <bsl...@gmail.com> wrote:
> Is there a simple way to make a form return to the referring page on a save
> or cancel?  I have links to edit an item from 2 different locations in my
> app and I'd like the user returned to the page that they used to get to edit
> the item instead of a fixed page.
>
> Bob
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/tXLi-dYNrNgJ.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to

Bryan Larsen

unread,
Mar 7, 2012, 10:10:27 PM3/7/12
to hobo...@googlegroups.com
On Wed, Mar 7, 2012 at 9:58 PM, Bob Sleys <bsl...@gmail.com> wrote:
> I'm sure I'm doing something dumb again, when isn't that the case.

I wouldn't call it dumb, it's a common mistake. I think we need to
start a manual page: "Frequent questions & misunderstandings". Top
of the list would be an explanation of the difference between no
colon, colon at the end and colon in the middle.

I also really wish we could make Hobo throw an error when people used
an undefined parameter. Unfortunately, that's not an easy fix to
Hobo, and would break a significant part of Rapid.

For that's what you've done here.

<after-submit: go-back/> means "add the go-back attribute to the
after-submit parameter". But the form doesn't have an after-submit
parameter, so the line is completely ignored.

you want

<after-submit go-back/> without the colon. However, you can't stick
it there because you can't mix parameter and non-parameter statements
-- where would the non-parameter statements go? The easiest solution
is just to throw it inside your actions, but a "better" solution would
be to explicitly place it:

<append-field-list:> <after-submit go-back/> </append-field-list:>

Bryan

>> > hobousers+...@googlegroups.com.


>> > For more options, visit this group at
>> > http://groups.google.com/group/hobousers?hl=en.
>

> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/hobousers/-/gepIH_v176gJ.


>
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to

> hobousers+...@googlegroups.com.

Bob Sleys

unread,
Mar 8, 2012, 9:56:33 AM3/8/12
to hobo...@googlegroups.com
Yes I still don't have that down and find it very confusing.  I just end up trying to remove/add colons to make the error mixed parameter error go a way but don't really understand it.

I'll give it another go and perhaps some year I'll understand what it all means.

Thanks again

Bob


>> > For more options, visit this group at
>> > http://groups.google.com/group/hobousers?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/gepIH_v176gJ.
>
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to

Bob Sleys

unread,
Mar 9, 2012, 9:09:38 AM3/9/12
to hobo...@googlegroups.com
Ok I tried both options and neither worked for me.  The <append-field-list:> option caused all my other tweaks to the field list to be skipped, ie. I get the default auto generated form.  Adding it to the actions section did nothing.

Bob

Bryan Larsen

unread,
Mar 9, 2012, 10:22:48 AM3/9/12
to hobo...@googlegroups.com
On Fri, Mar 9, 2012 at 9:09 AM, Bob Sleys <bsl...@gmail.com> wrote:
> Ok I tried both options and neither worked for me.  The <append-field-list:>
> option caused all my other tweaks to the field list to be skipped, ie. I get
> the default auto generated form.

Can you please post your DRYML for this? There's probably a typo in
there somewhere.

> Adding it to the actions section did
> nothing.

What version of Hobo are you using? It's certainly possible that I
broke it in 1-3-no-prototype or 1.4...

Bryan

Bob Sleys

unread,
Mar 9, 2012, 10:42:28 AM3/9/12
to hobo...@googlegroups.com
it's rather long but here is goes

<extend tag="form" for="LocationMaterial">
<old-form merge  >
<field-list: fields="material, abated, condition, potential, friable, percent_damage, accessible, quantity, unit, notes, locmathists">
<material-view:>
<select-one-or-new-dialog>
<field-list: fields="name"/>
</select-one-or-new-dialog>
</material-view:>
<unit-view:>
<select-one-or-new-dialog/>
</unit-view:>
<locmathists-label:>Changes</locmathists-label:>
<locmathists-view:>
<input-many template="&Locmathist.new(:field_tech => @current_user, :project => @current_project)">
<default: width="100%">
<card>
<header:></header:>
<body:>
<field-list fields="project, field_tech, date, comment">
<project-view:>
<select-one options="&@projects" text-method="list_name" blank-message="Select Project">
</select-one>
</project-view:>
</field-list>
</body:>
</card>
</default:>
<add-item:>
Add
</add-item:>
<remove-item:>
Remove
</remove-item:>
<empty-message:>
No History
</empty-message:>
</input-many>
</locmathists-view:>
</field-list:>
                <append-field-list:>  <after-submit go-back/> </append-field-list:>
<actions:>
<after-submit go-back/>
<submit label="#{ht 'location_material.actions.save', :default=>['Save']}" param/>
<or-cancel:location param="cancel"/>
</actions:>
</old-form>
</extend>

I only have one of the two highlighted lines in just showing both things I've tried.

Bryan Larsen

unread,
Mar 9, 2012, 10:46:40 AM3/9/12
to hobo...@googlegroups.com
I don't see anything obviously wrong -- I'll add it to my pile of
things to test out.

What version of Hobo are you using?

Bryan

> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/hobousers/-/RDEORnLs-J0J.


>
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to

> hobousers+...@googlegroups.com.

Bob Sleys

unread,
Mar 9, 2012, 11:27:53 AM3/9/12
to hobo...@googlegroups.com
GRR sorry forgot to add that

gem 'hobo', :git => 'git://github.com/tablatom/hobo.git', :branch => 'jquery'
gem "jquery-rails"
gem "hobo-jquery", :git => "git://github.com/bryanlarsen/hobo-jquery.git", :branch => "1-3-no-prototype"

Bob
Reply all
Reply to author
Forward
0 new messages