Zend_Dojo_Form not rendering in layout

I have a quick question about adding Zend_Dojo_Form to Zend_layouts.

I have a Zend_Dojo_Form that I want to display in a layout that is used for a specific controller. I can add the form to the layout without any problems, however the dojo elements cannot display as it would if I added the form to the standard view.

Is there a reason why this is so? Do I need to do something with the layout so that it includes the components for this inline form in the layout. Any other supported dojo forms that are added to the view using this layout work fine.

My form is created in the usual way:

class QuickAddJobForm extends Zend_Dojo_Form{


public function init(){

    $this->setName('quickaddjobfrm')
        ->setMethod('post')
        ->setAction('/addjob/start/);


    /*We now create the elements*/
    $jobTitle = new Zend_Dojo_Form_Element_TextBox('jobtitle',
        array(
            'trim' => true              
        )
    );
    $jobTitle->setAttrib('style', 'width:200px;')
        ->addFilter('StripTags')
        ->removeDecorator('DtDdWrapper')
        ->removeDecorator('HtmlTag')
        ->removeDecorator('Label');

      ....
  $this->addElements(array($jobTitle, ....));

In the controller, I declare the layout and form in the init function:

 public function init(){
   $this->_helper->layout->setLayout('add-layout');
   $form = new QuickAddJobForm();
   $form->setDecorators(array(array('ViewScript', array('viewScript' => 'quickAddJobFormDecorator.phtml'))));

 $this->_helper->layout()->quickaddjob = $form;

In my layout Where do I want my form to be:

  echo $this->layout()->quickaddjob;

/ dojo? , , , , ComboBoxes/FilteringSelects ..

.

0
3

, layout.phtml

<head>

    <style type="text/css" media="screen">
        @import url("<?= Zend_Controller_Front::getInstance()->getBaseUrl() ?>/includes/js/dojo/dijit/themes/tundra/tundra.css");

<?php
$this->dojo()->enable();
    if ($this->dojo()->isEnabled()) {
        $this->dojo()->setLocalPath($this->baseUrl() .  '/includes/js/dojo/dojo/dojo.js');
        echo $this->dojo();
    }
?>
</head>
<body class="tundra">

    protected function _initDojo()
{
    $this->bootstrap('frontController');
    $this->bootstrap('view');
    $view = $this->getResource('view');

    $appConfig = Zend_Controller_Front::getInstance()->getParam('appconfig');
    Zend_Dojo::enableView($view);
    Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
    $view->dojo()->setLocalPath(Zend_Controller_Front::getInstance()->getBaseUrl() . '/includes/js/dojo/dojo/dojo.js')
    ->addLayer(Zend_Controller_Front::getInstance()->getBaseUrl() . '/includes/js/dojo/dojo/nirvanaDojo.js')
    ->requireModule('dijit.TitlePane')
    ->requireModule('dijit.InlineEditBox')
    ->requireModule('dijit.ProgressBar')
    ->requireModule('dijit.form.DateTextBox')
    ->addStyleSheetModule('dijit.themes.tundra');
}

$this- > , Dojo

: Dojo

0

100% , , Dojo .

 $this->dojo()->enable(); 
 echo $this->dojo(); 

Layout.phtml

0

Zend_Dojo_Forms ,

echo $this → dojo();

- :

//in HTML-Head:
$content = $form->render();
echo $this->dojo();

//later...
echo $content;
0

Source: https://habr.com/ru/post/1767332/


All Articles