diff --git a/demos/form/form.php b/demos/form/form.php index ffc21449a8..46bd95ffb4 100644 --- a/demos/form/form.php +++ b/demos/form/form.php @@ -80,6 +80,7 @@ $form->onSubmit(function (Form $form) { $message = 'field = ' . print_r($form->model->get('field'), true) . ';
control = ' . print_r($form->model->get('control'), true); $view = new Message('Date field vs control:'); + $view->setApp($form->getApp()); $view->invokeInit(); $view->text->addHtml($message); @@ -112,6 +113,7 @@ $form->buttonSave->set('Save3'); $form->onSubmit(function (Form $form) { $view = new Message('some header'); + $view->setApp($form->getApp()); $view->invokeInit(); $view->text->addParagraph('some text ' . random_int(1, 100)); @@ -124,6 +126,7 @@ $form->buttonSave->set('Save4'); $form->onSubmit(function (Form $form) { $view = new Message('some header'); + $view->setApp($form->getApp()); $view->invokeInit(); $view->text->addParagraph('some text ' . random_int(1, 100)); diff --git a/docs/app.rst b/docs/app.rst index 56c5032286..a07f283009 100644 --- a/docs/app.rst +++ b/docs/app.rst @@ -9,10 +9,8 @@ Purpose of App class .. php:namespace:: Atk4\Ui .. php:class:: App -App is a mandatory object that's essential for Agile UI to operate. If you don't create App object explicitly, it -will be automatically created if you execute `$component->invokeInit()` or `$component->render()`. - -In most use-scenarios, however, you would create instance of an App class yourself before other components:: +App is a mandatory object that's essential for Agile UI to operate. You should create instance +of an App class yourself before other components:: $app = new \Atk4\Ui\App('My App'); $app->initLayout([\Atk4\Ui\Layout\Centered::class]); diff --git a/docs/overview.rst b/docs/overview.rst index 9757237beb..da83f2c49b 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -228,6 +228,7 @@ of application layout with a line:: To render a component individually and get the HTML and JavaScript use this format:: $form = new Form(); + $form->setApp($app); $form->invokeInit(); $form->setModel(new User($db)); diff --git a/src/View.php b/src/View.php index 61ff0c2e34..9339ed9007 100644 --- a/src/View.php +++ b/src/View.php @@ -505,9 +505,7 @@ public function removeAttr($property) public $stickyArgs = []; /** - * Build an URL which this view can use for js call-backs. It should - * be guaranteed that requesting returned URL would at some point call - * $this->invokeInit(). + * Build an URL which this view can use for JS callbacks. * * @param array $page */ @@ -517,9 +515,7 @@ public function jsUrl($page = []): string } /** - * Build an URL which this view can use for call-backs. It should - * be guaranteed that requesting returned URL would at some point call - * $this->invokeInit(). + * Build an URL which this view can use for callbacks. * * @param string|array $page URL as string or array with page name as first element and other GET arguments */