Submit on addTabURL not working when same page is added more than once.

24 views
Skip to first unread message

Willem Rheeder

unread,
Aug 21, 2014, 10:29:09 AM8/21/14
to agile-too...@googlegroups.com
Hi,

I am having issues with a "Dynamic Page" I load using addTabURL.


$tabs->addTabURL($this->api->url('ApplicationPages', array('app_page' => $page['page_name'],....));


The page is supposed to load a model based on some of the variables passed in the url and then create a form with submit button to update the model.

The first Tab's submit is working, but the rest of the tabs produce ajax error when submitted.

Application Error: js()->..->execute() must be used in response to form submission or AJAX operation only




<?php

class Page_ApplicationPages extends Page_ApplicationPage {

    function init() {
        parent::init();
        
        $m_form_model = $this->add('Model_ApplicationPageGenericModel');
        $f->setModel($m_form_model);
        
        $f->addSubmit($_GET['app_page']);
        
            
        
        if($f->isSubmitted()){
            $this->js()->univ()->successMessage('success!')->execute();
        }
        
    }

}

Romans Malinovskis

unread,
Aug 22, 2014, 10:12:43 AM8/22/14
to agile-too...@googlegroups.com
I think this is due to the same names within runtime tree.

Agile Toolkit attempts to give a separate name to each object (http://book.agiletoolkit.org/agiletoolkit-overview.html#objects-live-in-a-runtime-tree). When two objects have the same
name, it causes problems.


In your case it seems because you are adding same page twice, you might have the name clash. I'm not 100% sure about this though, so if you provide more details, it would be great.

Romans

Willem Rheeder

unread,
Aug 25, 2014, 3:27:30 AM8/25/14
to agile-too...@googlegroups.com
Hi Romans,

thanx for taking the time. 

I tested this by creating 3 uniquely named pages and submit worked fine.

Is there a way I can generate a different page name?  

Regards,
Willem

Willem Rheeder

unread,
Aug 25, 2014, 3:59:58 AM8/25/14
to agile-too...@googlegroups.com
Hi Romans,

sorry.  I was staring at code for so long I didn't realize an easy fix would be to change the name of the submit button 

$f->addSubmit($_GET['app_page'],'app_page_'.$_GET['app_page_id']);

and then to 

run the js on the form itself and not $this.

if($f->isSubmitted()){
            $f->js()->univ()->successMessage('dddd!')->execute();

Romans Malinovskis

unread,
Aug 28, 2014, 9:51:36 AM8/28/14
to agile-too...@googlegroups.com
yeah.

or what i also was using - adding everything into a view

$v = $this->add('View', 'v_' . (int)$_GET['app_page_id']);

anything inserted into this view would have unique IDs. Of course you might also need to make app_page_id sticky.
Reply all
Reply to author
Forward
0 new messages