开发者

Zend Framework AjaxContext filters the results and Decorators not removable

Ok, since this problem has 2 parts, it will be easier to explain them together. So here goes:

  1. I am trying to remove the default decorators from these elements, since I am using a little different way of styling them. But no matter what i do, the DtDDWrapper still shows up. If I try to remove all of the decorators, all of the fields below disappear.

    public function newfieldAction() {
    
    
    $ajaxContext = $this->_helper->getHelper('AjaxContext');
    $ajaxContext->addActionContext('newfield', 'html')->initContext();
    
    
    $id = $this->_getParam('id', null);
    $id1=$id+1;
    $id2=$id+2;
    
    
    $element = new Zend_Form_Element_Text("newTitle$id1");
    $element->setOptions(array('escape'=>false));
    $element->setRequired(true)->setLabel('Vertība')->removeDecorator('label');
    $tinyelement=new Zend_Form_Element_Text("newName$id");
    $tinyelement->setRequired(true)->setOptions(array('escape'=>false))->setLabel('Vertība')->removeDecorator('label');
    $textarea_element = new Zend_Form_Element_Textarea("newText$id2");
    $textarea_element->setRequired(true)->setOptions(array('escape'=>false))->setLabel('Vertība')->removeDecorator('label');
    
    
    $this->view->descriptionField = "<td>".$textarea_element->__toString()."</td>";
    $this->view->titleField = $el开发者_JS百科ement->__toString();
    $this->view->field = $tinyelement->__toString();
    $this->view->id=$id;
    }
    
  2. The context view script seams to trim my code in one way or another. When I try to put a <td> or a <table> tag in the view script, it just skips the tags. Is there a way to stop this escaping from happening? My view script:

    <tr class="element<php echo $this->id; ?>">
    asdfasdfasdfasd
    <td><?php echo $this->field ?></td>
    <td><php echo $this->titleField ?></td>
    <td><php echo $this->descriptionField ?></td>
    
    
    <td><a class="remove-element" rel="<php echo $this->id ?>">remove</a></td>
    
    
    </tr>
    

P.S. the code formatting system is barfing at me, could someone please help me with the formatting of the code?


Decorators

At a minimum, you need to set the ViewHelper decorator. This is the one that renders the element itself.

To disable the default decorators, the easiest way to do so is via the element constructor by either setting the decorators via the decorators option or setting the disableLoadDefaultDecorators option to false (but you will still need to set decorators later). For example

$element = new Zend_Form_Element_Text("newTitle$id1", array(
    'decorators' => array('ViewHelper')
));

View Script

You will need to elaborate what you mean by "skips the tags". Apart from that asdfasdfasdfasd out of place string in your markup, I can't see any problem.

This may also be effected by where in the DOM you're loading / placing the AJAX context. Loading it in the wrong place, creating invalid markup may make it appear to not display correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜