views:

26

answers:

1

the side bar is in the layout.phtml file. i am very confused why does adding 1 decorator to my form, cause my sidebar ... hmm actually its every thing after that section#main - i am using HTML5 - to go missing

layout.phtml

... /* scripts and all */ ...
<body>
    <header> ... </header>
    <nav> ... </nav>
    <div class="clear" />

    <section id="main">
        <?php echo $this->navigation()->breadcrumbs(); ?>
        <?php echo $this->layout()->content; ?>
    </section>

    <aside id="sidebar"> ... </aside>
    <footer> ... </footer>
</body>

everything after section#main is missing.

my custom decorator is simply

class Application_Form_Decorator_WmdPreview extends Zend_Form_Decorator_Abstract {
    function render($content) {
        $separator = $this->getSeparator();
        $html = '<label style="margin-top: 10px">Preview</label><div class="wmd-preview" />';

        switch ($this->_placement) {
            case self::APPEND:
                return $content . $separator . $html;
            case self::PREPEND:
                return $html . $separator . $content;
        }
    }
}

and my form init() -

... // adding form elements 

// call loading of default decorators manually
$this->loadDefaultDecorators();
// override decorator for body
$this->getElement('body')
     ->setDecorators(array(
        'ViewHelper',
        'Errors',
        array('Description', array('tag' => 'p', 'escape' => false)),
        'Label',
        new Application_Form_Decorator_WmdPreview,
        array('HtmlTag', array('tag' => 'p'))
     ));
// disable autoloading of default decorators 
$this->setDisableLoadDefaultDecorators(true);

... hmm ... something i notice now is that html from view source is ok

<p><label for="body" class="optional">Post body</label>
<textarea name="body" id="body" rows="24" cols="80"></textarea>
<label style="margin-top: 10px">Preview</label><div class="wmd-preview" /></p>

but output from firebug is not ...

...
<textarea name="body" id="body" rows="24" cols="80"></textarea>
<label style="margin-top: 10px">Preview</label>
</p> <!-- why is this here !!! -->
<div class="wmd-preview">...</div><!-- and this out of the p!!! -->
</form>
</section>
<!-- all my content supposed to be here is missing! -->
</body>

javascript problem? from WMD?

Solution

instead of using <div /> use <div></div>. also like @DavidW says, i shld not have a <div> inside a <p>

+2  A: 

I believe that a <p> tag can only contain phrasing content. In particular, the <div> inside the <p> renders the HTML invalid. Firefox/Firebug may be doing the best it can, but ends up choking on it. Perhaps using a <span> rather than a div would solve the problem.

David Weinraub
Or just not putting it in a <p> to start with. A div looks suited for his purposes.
Iznogood
hmm if i just put the whole thing outside the p, it still does not work ...
jiewmeng
hmm i found the problem seems to be "`<div />`" vs "`<div></div>`" but is "`<div />`" invalid?
jiewmeng