1

I'm using agile toolkit 4.3.2. I have a virtual page that contains a form.

I created a button:

$this->button = $this->addButton('')
            ->setAttr('title', 'Show Virtual Page');

And I binded the virtual page to this button:

$vp = $this->button->add('VirtualPage', $size)->bindEvent('Show Virtual Page', 'click');

What I want is to get the HTML of the virtual page without pressing a Button. How can I do that? I want to have the HTML in a variable to pass it to another location in order to render it later.

Please tell me how can I get the HTML of a virtual page without pressing a button. I want to have the content after the page is loaded. How can I do that?

Pascut
  • 3,291
  • 6
  • 36
  • 64
  • I don't see reason why You would need to add VirtualPage to the button. Can you explain in more details what you are trying to accomplish? – DarkSide Dec 05 '16 at 21:27
  • I answered to this question as a reply to your answer. – Pascut Dec 06 '16 at 15:59

1 Answers1

0

This is example how you can add button in page and when you click on that button, then dialog will open in which you'll see virtual page with any content you want:

$b = $page->add('Button')->set('Open popup');
$vp = $b->add('VirtualPage')
    ->bindEvent('My Cool Title','click')
    ->set(function($page){
        $page->add('LoremIpsum');
    });

I am not sure why you would want to get HTML of that VirtualPage. You have to avoid to work directly with html code anyway :)

Anyway in this case VirtualPage will not be rendered at all while button is not clicked.

In some cases you can try to use $vp->getPage()->getHTML();

DarkSide
  • 3,670
  • 1
  • 26
  • 34
  • I have a custom form in a popup (modal). I want to copy the HTML from that modal to a variable in order to display it later. Code: $vp->getPage()->getHTML(); displays an empty html with empty head and body tags. – Pascut Dec 06 '16 at 15:59
  • What you mean by "... to display it later"? Later when? VirtualPage is a page not a form or simple view. If it is called by specific URL (see $vp->getURL()) then it will replace apps original page with its own output. – DarkSide Dec 08 '16 at 20:26
  • You are right here. That's not a good solution. My actual problem is that there's no solution for getting form HTML in order to display it manual where I want on the page. For example I'm rendering a form for each grid's column on a page. – Pascut Dec 09 '16 at 09:33
  • So you want to add form inside grid column? That can be tricky because atk grid doesn't support that out of the box. But there always is solution, for example, custom grid template and custom column formatter which adds form inside grid template. Anyway - it's no need for VirtualPage in this case. What exactly do you need to accomplish? – DarkSide Dec 11 '16 at 22:41