How do I change the View after a save in 1.6

497 views
Skip to first unread message

Brad Gies

unread,
Jan 17, 2011, 4:59:43 AM1/17/11
to joomla-...@googlegroups.com

I'm writing an extension for 1.6 and I think I finally figured out most
of the validation part.. (by the way, I really like how JForm and the
Form rules work).

When I am in the list; I click on the "New" button and get my input
form, fill it out, and click "Save". The entry goes into the database,
but I don't see any way to tell it which view I want it to go to after
the save (at least not an obvious way). It seems to just add an "s" to
the input form view... and I don't have a view named that way.

So... how do I tell it what the List view name is?

I guess I could look for the view name with the "s" at the end and
redirect it in the main controller... but that seems like a hack. How am
I supposed to give it the view name?


Sincerely,

Brad Gies
-----------------------------------------------------------------------
Bistro Bot - Bistro Blurb
http://bgies.com http://nocrappyapps.com
http://bistroblurb.com http://forcethetruth.com
http://ihottonight.com
-----------------------------------------------------------------------
Everything in moderation, including abstinence (paraphrased)

Every person is born with a brain... Those who use it well are the successful happy ones - Brad Gies

Adversity can make or break you... It's your choice... Choose wisely - Brad Gies

Never doubt that a small group of thoughtful, committed people can
change the world. Indeed. It is the only thing that ever has - Margaret Mead

Michael Babker

unread,
Jan 17, 2011, 5:11:33 AM1/17/11
to joomla-...@googlegroups.com
In your save method you could do a $this->setRedirect from the controller.
TemplatesControllerSource::save might give you the best example to work
with.

Michael Babker
Owner, FLBab.com
"Never be bullied into silence. Never allow yourself to be made a victim.
Accept no one's definition of your life; define yourself." - Harvey
Fierstein


Sincerely,

--
You received this message because you are subscribed to the Google Groups
"Joomla! CMS Development" group.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to
joomla-dev-cm...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/joomla-dev-cms?hl=en-GB.

Brad Gies

unread,
Jan 17, 2011, 3:24:19 PM1/17/11
to joomla-...@googlegroups.com
I hate to admit this... but it took me about 1/2 an hour of thinking to
get it clear in my mind where to put (override) the save method... and
about 3 minutes to code and test it :). I ended up with this :

public function save($key = null, $urlVar = null)
{
$retVal = parent::save($key, $urlVar);
if ($retVal)
{

$this->setRedirect(JRoute::_('index.php?option=com_doubleadsense&view=adsenselist',
'New item was inserted'));

}
}


Thanks...

Sincerely,

Brad Gies
-----------------------------------------------------------------------
Bistro Bot - Bistro Blurb
http://bgies.com http://nocrappyapps.com
http://bistroblurb.com http://forcethetruth.com
http://ihottonight.com
-----------------------------------------------------------------------
Everything in moderation, including abstinence (paraphrased)

Every person is born with a brain... Those who use it well are the successful happy ones - Brad Gies

Adversity can make or break you... It's your choice... Choose wisely - Brad Gies

Never doubt that a small group of thoughtful, committed people can
change the world. Indeed. It is the only thing that ever has - Margaret Mead

Ian MacLennan

unread,
Jan 17, 2011, 3:36:48 PM1/17/11
to joomla-...@googlegroups.com
What controller class are you extending?

In JControllerForm you can set $this->view_item and $this->view_list.  In JControllerAdmin you can set $this->view_list.

Ian



Reply all
Reply to author
Forward
0 new messages