2008年11月7日星期五

Re: [fw-mvc] Dojo form not working on placeholders in layout file


On 7 Nov 2008, at 11:06, Carlton Gibson wrote:


On 7 Nov 2008, at 10:33, Zladivliba Voskuy wrote:

Hi everyone, 

I can't seem to get dojo to work on a placeholder located in my layout file.
The form is a simple login form that works fine. However when I try to put it in the placeholder the form shows but without dojo applying to it. 
Here's an extract : 

This doesn't work, on my index.phtml :

$login = new Login();
$this->placeholder('loginbox')->set($login);

Here's the target in my layout file : 
<?php echo $this->placeholder('loginbox'); ?>

However this works fine in the index.phtml : 
$login = new Login();
echo $login ;
 
Any idea how do deal with this bug ?

This is just a guess as I'm a YUI man myself but, one possibility is that because the placeholder is being rendered in the layout script whatever call is being made to the dojo view helper is occurring AFTER its stuff has already been added to the <head>. (Thus whatever dojo magic you're after doesn't happen.)

Sorry, new suggestion. 

The simplest thing for you to do is to type cast the $login object as a string when you assign it to the placeholder. This causes it's __toString() method to be called (and so the required call to the dojo view helper as well): 

In your index.phtml:

$login = new Login();
$this->placeholder('loginbox')->set( (string) $login );

Hopefully that works for you. 
Carlton

没有评论: