unable to disable Dojo

9 messages Options
Embed this post
Permalink
Guillaume Oriol

unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
Hi, I am facing a problem with Dojo: I set up Dojo to be disabled by default but it is still enabled in my login form.

  1. I've put in my bootstrap file those two lines (set up Dojo environment but disable it by default):
          Zend_Dojo::enableView($view);
          $view->dojo()->disable();
    
  2. Then, in my authentication controller:
          class AuthController extends Zend_Controller_Action
          {
              function loginAction()
              {
                  $form = new Form_Login();
                  // ...
                  $this->view->dojo()->disable(); // just to be sure
                  $this->view->title = "Authentication";
                  $this->view->form = $form;
              }
          }
    
  3. My form extends Zend_Form (NOT Zend_Dojo_Form). Furthermore, I only use plain elements that are not Dijits : Zend_Form_Element_Text, Zend_Form_Element_Password et Zend_Form_Element_Submit.
  4. My view script is very short:
          <?php $this->headLink()->appendStylesheet($this->staticUrl('style/form.css')); ?>
          <h1><?php echo $this->escape($this->title); ?></h1>
          <?php echo $this->form; ?>
    
  5. And this view script is invoked by the layout where one can find:
          <?php
          if ($this->dojo()->isEnabled()) {
              $this->dojo()->addStyleSheetModule('dijit.themes.tundra');
              echo $this->dojo();
          }
          ?>
    
But, in the generated HTML page, I find in the HEAD tag:
<style type="text/css">
<!--
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.2.0/dijit/themes/tundra/tundra.css";
-->
</style>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.2.0/dojo/dojo.xd.js"></script>

<script type="text/javascript">
//<![CDATA[
dojo.require("dijit.form.Form");
    dojo.require("dojo.parser");
dojo.addOnLoad(function() {
    dojo.forEach(zendDijits, function(info) {
        var n = dojo.byId(info.id);
        if (null != n) {
            dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
        }
    });
    dojo.parser.parse();
});
var zendDijits = [{"id":"auth","params":{"dojoType":"dijit.form.Form"}}];
//]]>

</script>
What's wrong?
weierophinney

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
-- Guillaume Oriol <[hidden email]> wrote
(on Thursday, 04 December 2008, 01:38 AM -0800):
> Hi, I am facing a problem with Dojo: I set up Dojo to be disabled by default
> but it is still enabled in my login form.
>
>
>  1. I've put in my bootstrap file those two lines (set up Dojo environment but
>     disable it by default):
<snip>
>  2. Then, in my authentication controller:
<snip>
>  3. My form extends Zend_Form (NOT Zend_Dojo_Form). Furthermore, I only use
>     plain elements that are not Dijits : Zend_Form_Element_Text,
>     Zend_Form_Element_Password et Zend_Form_Element_Submit.
>  4. My view script is very short:
<snip>
>  5. And this view script is invoked by the layout where one can find:
<snip>
>
> But, in the generated HTML page, I find in the HEAD tag:
<snip - finds dojo artifacts>

So, Zend_Dojo_Form utilizes the Dojo form view helper.. so rendering
your form renders that helper. All Dijit view helpers, on instantiation,
enable the dojo() view helper. So, my recommendations are to either:

  * not use Zend_Dojo_Form if you're not actually using any
    dojo-specific elements
  * Call $this->dojo()->disable(); after you render the form

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
Guillaume Oriol

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
Thank you Matthew for your answer
but I don't use Zend_Dojo_Form in my form, neither any Dijit.
My form extends Zend_Form.

Why would ZF enable Dojo in such a case?

Matthew Weier O'Phinney-3 wrote:
-- Guillaume Oriol <goriol@technema.fr> wrote
(on Thursday, 04 December 2008, 01:38 AM -0800):
> Hi, I am facing a problem with Dojo: I set up Dojo to be disabled by default
> but it is still enabled in my login form.
>
>
>  1. I've put in my bootstrap file those two lines (set up Dojo environment but
>     disable it by default):
<snip>
>  2. Then, in my authentication controller:
<snip>
>  3. My form extends Zend_Form (NOT Zend_Dojo_Form). Furthermore, I only use
>     plain elements that are not Dijits : Zend_Form_Element_Text,
>     Zend_Form_Element_Password et Zend_Form_Element_Submit.
>  4. My view script is very short:
<snip>
>  5. And this view script is invoked by the layout where one can find:
<snip>
>
> But, in the generated HTML page, I find in the HEAD tag:
<snip - finds dojo artifacts>

So, Zend_Dojo_Form utilizes the Dojo form view helper.. so rendering
your form renders that helper. All Dijit view helpers, on instantiation,
enable the dojo() view helper. So, my recommendations are to either:

  * not use Zend_Dojo_Form if you're not actually using any
    dojo-specific elements
  * Call $this->dojo()->disable(); after you render the form

--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/
weierophinney

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
-- Guillaume Oriol <[hidden email]> wrote
(on Thursday, 04 December 2008, 11:40 PM -0800):
> Thank you Matthew for your answer
> but I don't use Zend_Dojo_Form in my form, neither any Dijit.
> My form extends Zend_Form.
>
> Why would ZF enable Dojo in such a case?

I know what's going on.

There is a standard view helper, Form, and one of the same name in the
Zend_Dojo_View_Helper tree. Because your view object has been
initialized with the Dojo view helper path, it's finding the Dojo Form
view helper and using that over the standard one.

The easiest way around this is to, in your form's render method, remove
the Dojo view helper path:

    public function render(Zend_View_Interface $view = null)
    {
        if (null === $view) {
            $view = $this->getView();
        }
        $loader = $view->getPluginLoader('helper');
        if ($loader->getPaths('Zend_Dojo_View_Helper')) {
            $loader->removePrefixPath('Zend_Dojo_View_Helper');
        }
        return parent::render($view);
    }


> Matthew Weier O'Phinney-3 wrote:
> >
> > -- Guillaume Oriol <[hidden email]> wrote
> > (on Thursday, 04 December 2008, 01:38 AM -0800):
> >> Hi, I am facing a problem with Dojo: I set up Dojo to be disabled by
> >> default
> >> but it is still enabled in my login form.
> >>
> >>
> >>  1. I've put in my bootstrap file those two lines (set up Dojo
> >> environment but
> >>     disable it by default):
> > <snip>
> >>  2. Then, in my authentication controller:
> > <snip>
> >>  3. My form extends Zend_Form (NOT Zend_Dojo_Form). Furthermore, I only
> >> use
> >>     plain elements that are not Dijits : Zend_Form_Element_Text,
> >>     Zend_Form_Element_Password et Zend_Form_Element_Submit.
> >>  4. My view script is very short:
> > <snip>
> >>  5. And this view script is invoked by the layout where one can find:
> > <snip>
> >>
> >> But, in the generated HTML page, I find in the HEAD tag:
> > <snip - finds dojo artifacts>
> >
> > So, Zend_Dojo_Form utilizes the Dojo form view helper.. so rendering
> > your form renders that helper. All Dijit view helpers, on instantiation,
> > enable the dojo() view helper. So, my recommendations are to either:
> >
> >   * not use Zend_Dojo_Form if you're not actually using any
> >     dojo-specific elements
> >   * Call $this->dojo()->disable(); after you render the form
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect       | [hidden email]
> > Zend Framework           | http://framework.zend.com/
> >
> >
>
>
> -----
> Guillaume ORIOL
> Sofware architect
> Technema
> --
> View this message in context: http://www.nabble.com/unable-to-disable-Dojo-tp20830062p20849091.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
Guillaume Oriol

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
Thank you Matthew.
Once again you've found the answer AND the solution.
--
Best regards

Matthew Weier O'Phinney-3 wrote:
-- Guillaume Oriol <goriol@technema.fr> wrote
(on Thursday, 04 December 2008, 11:40 PM -0800):
> Thank you Matthew for your answer
> but I don't use Zend_Dojo_Form in my form, neither any Dijit.
> My form extends Zend_Form.
>
> Why would ZF enable Dojo in such a case?

I know what's going on.

There is a standard view helper, Form, and one of the same name in the
Zend_Dojo_View_Helper tree. Because your view object has been
initialized with the Dojo view helper path, it's finding the Dojo Form
view helper and using that over the standard one.

The easiest way around this is to, in your form's render method, remove
the Dojo view helper path:

    public function render(Zend_View_Interface $view = null)
    {
        if (null === $view) {
            $view = $this->getView();
        }
        $loader = $view->getPluginLoader('helper');
        if ($loader->getPaths('Zend_Dojo_View_Helper')) {
            $loader->removePrefixPath('Zend_Dojo_View_Helper');
        }
        return parent::render($view);
    }


> Matthew Weier O'Phinney-3 wrote:
> >
> > -- Guillaume Oriol <goriol@technema.fr> wrote
> > (on Thursday, 04 December 2008, 01:38 AM -0800):
> >> Hi, I am facing a problem with Dojo: I set up Dojo to be disabled by
> >> default
> >> but it is still enabled in my login form.
> >>
> >>
> >>  1. I've put in my bootstrap file those two lines (set up Dojo
> >> environment but
> >>     disable it by default):
> > <snip>
> >>  2. Then, in my authentication controller:
> > <snip>
> >>  3. My form extends Zend_Form (NOT Zend_Dojo_Form). Furthermore, I only
> >> use
> >>     plain elements that are not Dijits : Zend_Form_Element_Text,
> >>     Zend_Form_Element_Password et Zend_Form_Element_Submit.
> >>  4. My view script is very short:
> > <snip>
> >>  5. And this view script is invoked by the layout where one can find:
> > <snip>
> >>
> >> But, in the generated HTML page, I find in the HEAD tag:
> > <snip - finds dojo artifacts>
> >
> > So, Zend_Dojo_Form utilizes the Dojo form view helper.. so rendering
> > your form renders that helper. All Dijit view helpers, on instantiation,
> > enable the dojo() view helper. So, my recommendations are to either:
> >
> >   * not use Zend_Dojo_Form if you're not actually using any
> >     dojo-specific elements
> >   * Call $this->dojo()->disable(); after you render the form
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect       | matthew@zend.com
> > Zend Framework           | http://framework.zend.com/
> >
> >
>
>
> -----
> Guillaume ORIOL
> Sofware architect
> Technema
> --
> View this message in context: http://www.nabble.com/unable-to-disable-Dojo-tp20830062p20849091.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>

--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/
jweber

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
How can you check if dojo is enabled in a view script then?  isEnabled() is unavailable after removing the Dojo view helper path.


Guillaume Oriol wrote:
Thank you Matthew.
Once again you've found the answer AND the solution.
--
Best regards

Matthew Weier O'Phinney-3 wrote:
-- Guillaume Oriol <goriol@technema.fr> wrote
(on Thursday, 04 December 2008, 11:40 PM -0800):
> Thank you Matthew for your answer
> but I don't use Zend_Dojo_Form in my form, neither any Dijit.
> My form extends Zend_Form.
>
> Why would ZF enable Dojo in such a case?

I know what's going on.

There is a standard view helper, Form, and one of the same name in the
Zend_Dojo_View_Helper tree. Because your view object has been
initialized with the Dojo view helper path, it's finding the Dojo Form
view helper and using that over the standard one.

The easiest way around this is to, in your form's render method, remove
the Dojo view helper path:

    public function render(Zend_View_Interface $view = null)
    {
        if (null === $view) {
            $view = $this->getView();
        }
        $loader = $view->getPluginLoader('helper');
        if ($loader->getPaths('Zend_Dojo_View_Helper')) {
            $loader->removePrefixPath('Zend_Dojo_View_Helper');
        }
        return parent::render($view);
    }


> Matthew Weier O'Phinney-3 wrote:
> >
> > -- Guillaume Oriol <goriol@technema.fr> wrote
> > (on Thursday, 04 December 2008, 01:38 AM -0800):
> >> Hi, I am facing a problem with Dojo: I set up Dojo to be disabled by
> >> default
> >> but it is still enabled in my login form.
> >>
> >>
> >>  1. I've put in my bootstrap file those two lines (set up Dojo
> >> environment but
> >>     disable it by default):
> > <snip>
> >>  2. Then, in my authentication controller:
> > <snip>
> >>  3. My form extends Zend_Form (NOT Zend_Dojo_Form). Furthermore, I only
> >> use
> >>     plain elements that are not Dijits : Zend_Form_Element_Text,
> >>     Zend_Form_Element_Password et Zend_Form_Element_Submit.
> >>  4. My view script is very short:
> > <snip>
> >>  5. And this view script is invoked by the layout where one can find:
> > <snip>
> >>
> >> But, in the generated HTML page, I find in the HEAD tag:
> > <snip - finds dojo artifacts>
> >
> > So, Zend_Dojo_Form utilizes the Dojo form view helper.. so rendering
> > your form renders that helper. All Dijit view helpers, on instantiation,
> > enable the dojo() view helper. So, my recommendations are to either:
> >
> >   * not use Zend_Dojo_Form if you're not actually using any
> >     dojo-specific elements
> >   * Call $this->dojo()->disable(); after you render the form
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect       | matthew@zend.com
> > Zend Framework           | http://framework.zend.com/
> >
> >
>
>
> -----
> Guillaume ORIOL
> Sofware architect
> Technema
> --
> View this message in context: http://www.nabble.com/unable-to-disable-Dojo-tp20830062p20849091.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>

--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/
fab2008

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
In reply to this post by weierophinney
Thank you for this post (of about 8 months ago...) it saves me a lot of time. But IMHO this behaviour should be avoided in some way by Zend_Form itself, it can be source of a lot of problems when using dojo only in a couple of pages (as in my case).

In every case, I solved my problem using your code in my form base class.

Hope that this will not bring any problem in the future releases.

Bye.

Matthew Weier O'Phinney-3 wrote:
-- Guillaume Oriol <goriol@technema.fr> wrote
(on Thursday, 04 December 2008, 11:40 PM -0800):
> Thank you Matthew for your answer
> but I don't use Zend_Dojo_Form in my form, neither any Dijit.
> My form extends Zend_Form.
>
> Why would ZF enable Dojo in such a case?

I know what's going on.

There is a standard view helper, Form, and one of the same name in the
Zend_Dojo_View_Helper tree. Because your view object has been
initialized with the Dojo view helper path, it's finding the Dojo Form
view helper and using that over the standard one.

The easiest way around this is to, in your form's render method, remove
the Dojo view helper path:

    public function render(Zend_View_Interface $view = null)
    {
        if (null === $view) {
            $view = $this->getView();
        }
        $loader = $view->getPluginLoader('helper');
        if ($loader->getPaths('Zend_Dojo_View_Helper')) {
            $loader->removePrefixPath('Zend_Dojo_View_Helper');
        }
        return parent::render($view);
    }
--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/
gerardroche

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
In reply to this post by weierophinney
Good work around, but shouldn't Zend_Form do this?

Matthew Weier O'Phinney-3 wrote:
-- Guillaume Oriol <goriol@technema.fr> wrote
(on Thursday, 04 December 2008, 11:40 PM -0800):
> Thank you Matthew for your answer
> but I don't use Zend_Dojo_Form in my form, neither any Dijit.
> My form extends Zend_Form.
>
> Why would ZF enable Dojo in such a case?

I know what's going on.

There is a standard view helper, Form, and one of the same name in the
Zend_Dojo_View_Helper tree. Because your view object has been
initialized with the Dojo view helper path, it's finding the Dojo Form
view helper and using that over the standard one.

The easiest way around this is to, in your form's render method, remove
the Dojo view helper path:

    public function render(Zend_View_Interface $view = null)
    {
        if (null === $view) {
            $view = $this->getView();
        }
        $loader = $view->getPluginLoader('helper');
        if ($loader->getPaths('Zend_Dojo_View_Helper')) {
            $loader->removePrefixPath('Zend_Dojo_View_Helper');
        }
        return parent::render($view);
    }


> Matthew Weier O'Phinney-3 wrote:
> >
> > -- Guillaume Oriol <goriol@technema.fr> wrote
> > (on Thursday, 04 December 2008, 01:38 AM -0800):
> >> Hi, I am facing a problem with Dojo: I set up Dojo to be disabled by
> >> default
> >> but it is still enabled in my login form.
> >>
> >>
> >>  1. I've put in my bootstrap file those two lines (set up Dojo
> >> environment but
> >>     disable it by default):
> > <snip>
> >>  2. Then, in my authentication controller:
> > <snip>
> >>  3. My form extends Zend_Form (NOT Zend_Dojo_Form). Furthermore, I only
> >> use
> >>     plain elements that are not Dijits : Zend_Form_Element_Text,
> >>     Zend_Form_Element_Password et Zend_Form_Element_Submit.
> >>  4. My view script is very short:
> > <snip>
> >>  5. And this view script is invoked by the layout where one can find:
> > <snip>
> >>
> >> But, in the generated HTML page, I find in the HEAD tag:
> > <snip - finds dojo artifacts>
> >
> > So, Zend_Dojo_Form utilizes the Dojo form view helper.. so rendering
> > your form renders that helper. All Dijit view helpers, on instantiation,
> > enable the dojo() view helper. So, my recommendations are to either:
> >
> >   * not use Zend_Dojo_Form if you're not actually using any
> >     dojo-specific elements
> >   * Call $this->dojo()->disable(); after you render the form
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect       | matthew@zend.com
> > Zend Framework           | http://framework.zend.com/
> >
> >
>
>
> -----
> Guillaume ORIOL
> Sofware architect
> Technema
> --
> View this message in context: http://www.nabble.com/unable-to-disable-Dojo-tp20830062p20849091.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>

--
Matthew Weier O'Phinney
Software Architect       | matthew@zend.com
Zend Framework           | http://framework.zend.com/
fabius

Re: unable to disable Dojo

Reply Threaded More More options
Print post
Permalink
In reply to this post by weierophinney
weierophinney wrote:
-- Guillaume Oriol <goriol@technema.fr> wrote
(on Thursday, 04 December 2008, 11:40 PM -0800):
> Thank you Matthew for your answer
> but I don't use Zend_Dojo_Form in my form, neither any Dijit.
> My form extends Zend_Form.
>
> Why would ZF enable Dojo in such a case?

I know what's going on.

There is a standard view helper, Form, and one of the same name in the
Zend_Dojo_View_Helper tree. Because your view object has been
initialized with the Dojo view helper path, it's finding the Dojo Form
view helper and using that over the standard one.

The easiest way around this is to, in your form's render method, remove
the Dojo view helper path:

    public function render(Zend_View_Interface $view = null)
    {
        if (null === $view) {
            $view = $this->getView();
        }
        $loader = $view->getPluginLoader('helper');
        if ($loader->getPaths('Zend_Dojo_View_Helper')) {
            $loader->removePrefixPath('Zend_Dojo_View_Helper');
        }
        return parent::render($view);
    }
How about filing this as a BUG, then? I didn't check ZF's bug tracking system, but it's been almost a year and it was never fixed.