2013-07-26 80 views
0

即時嘗試添加dynatree到zend表單中,我設法在我的zend項目中的普通頁面中實現dynatree ..ive添加了必要的代碼以顯示dynatree的html,但是它仍然不顯示。 所以在我的頁面中我有一個按鈕來調用添加表單。 這裏是代碼 /標籤/添加dynatree不能以zend的形式工作

public function addAction() 
{ 
    // action body 
     $this->_helper->layout()->setLayout('form-adr'); 
    $form = new Application_Form_Tags(); 

    $this->view->form = $form; 
} 

代碼佈局form_adr

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/reset.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/root.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/grid.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/typography.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/jquery-ui.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/jquery-plugin-base.css" /> 
    <!--dynatree--> 

<script src='/dynatree/jquery/jquery.cookie.js' type="text/javascript"></script> 

<link rel='stylesheet' type='text/css' href='/dynatree/src/skin/ui.dynatree.css'> 
<script src='/dynatree/src/jquery.dynatree.js' type="text/javascript"></script> 

</head> 
<body style="background:#fff;"> 

    <!--CONTENT--> 
    <?php echo $this->layout()->content; ?> 
    <!--//CONTENT--> 

</body> 
</html> 

代碼Application_Form_Tags

class Application_Form_Tags extends Zend_Form 
{ 

public function init() 
{ 
    /* Form Elements & Other Definitions Here ... */ 
     $name = new Zend_Form_Element_Text('nome'); 
    $name->setAttrib('class', 'st-forminput'); 
    $name->removeDecorator('DtDdWrapper'); 
    $name->removeDecorator('HtmlTag'); 
    $name->removeDecorator('Label'); 

    $descricao = new Zend_Form_Element_Text('descricao'); 
    $descricao->setAttrib('class', 'st-forminput'); 
    $descricao->removeDecorator('DtDdWrapper'); 
    $descricao->removeDecorator('HtmlTag'); 
    $descricao->removeDecorator('Label'); 

    $modo = new Zend_Form_Element_Select('modo');$modo->removeDecorator('DtDdWrapper'); 
    $modo->removeDecorator('HtmlTag'); 
    $modo->removeDecorator('Label'); 
    $modo->addMultiOptions(array('Activo' => 'Activo', 'Passivo' => 'Passivo')); 

    $estado = new Zend_Form_Element_Select('estado'); 
    $estado->removeDecorator('DtDdWrapper'); 
    $estado->removeDecorator('HtmlTag'); 
    $estado->removeDecorator('Label'); 
    $estado->addMultiOptions(array('Activada' => 'Activada', 'Desactivada' => 'Desactivada','Blacklist'=>'Blacklist')); 

    $cliente=new Zend_Form_Element_Select('cliente'); 
    $cliente->removeDecorator('DtDdWrapper'); 
    $cliente->removeDecorator('HtmlTag'); 
    $cliente->removeDecorator('Label'); 
    $client = new Application_Model_Clientes(); 
    $cliente->addMultiOption(0, 'Please select...'); 
    foreach ($client->fetchAll() as $oCountry) { 
     $cliente->addMultiOption($oCountry['id_cliente'], $oCountry['nome']); 
    } 


    $submit = new Zend_Form_Element_Submit('submit'); 
    $submit->removeDecorator('DtDdWrapper'); 
    $submit->removeDecorator('HtmlTag'); 
    $submit->removeDecorator('Label'); 

    $this->addElements(array(
     $name, 
     $descricao, 
     $modo, 
     $estado, 
     $cliente, 

     $submit 
    )); 

} 

的視圖add.phtml

代碼
<?php if($this->success): ?> 
<script> 
    window.parent.reloadGrid(); 
    window.parent.showMsgFromIframe('Utilizador adicionada com sucesso'); 
    window.parent.closeDialog(); 
</script> 
<?php exit; ?> 
<?php endif; ?> 

<?php if($this->hasError): ?> 
<div class="albox errorbox" style="margin:15px 10px 15px 0 !important;z-index: 690;"> 
    <b>Erro :</b> <?php echo $this->errorMessage; ?> 
</div> 
<?php endif; ?> 

<div class="simplebox grid740" style="padding-bottom:0 !important; width:680px !important;"> 

<form action="" method="post" name="form2" id="form3"> 


    <div class="st-form-line" style="z-index: 350;">  
     <span class="st-labeltext">Nome:</span> 
     <?php echo $this->form->getElement('nome'); ?> 
     <div class="clear" style="z-index: 340;"></div> 
    </div> 

    <div class="st-form-line" style="z-index: 350;">  
     <span class="st-labeltext">Descrição:</span>  
     <?php echo $this->form->getElement('descricao'); ?> 
     <div class="clear" style="z-index: 340;"></div> 
    </div> 









    <div class="st-form-line" style="z-index: 350;">  
     <span class="st-labeltext">Cliente:</span> 
     <?php echo $this->form->getElement('cliente'); ?> 
     <div class="clear" style="z-index: 340;"></div> 
    </div> 

    <div class="st-form-line" style="z-index: 350;">  
     <span class="st-labeltext">Modo:</span> 
     <?php echo $this->form->getElement('modo'); ?> 
     <div class="clear" style="z-index: 340;"></div> 
    </div> 


<!-- Add a <div> element where the tree should appear: --> 
<div class="st-form-line" style="z-index: 350;"> 
     <span class="st-labeltext">Localização:</span> 
     //javascript code 
     <script type="text/javascript"> 
var t=-1; 

$(function(){ 
    // Attach the dynatree widget to an existing <div id="tree"> element 
    // and pass the tree options as an argument to the dynatree() function: 
    $("#tree").dynatree({ 
     initAjax: { 
    url: "/locais/tree" 
    }, 
    onActivate: function(node) { 
    t=node.data.key; 
    }, 

    }); 

}); 

</script> 
     <div id="tree"> </div>-->intruction for the tree 
     <div class="clear" style="z-index: 340;"></div> 
    </div> 


    <div class="button-box" style="z-index: 460;"> 
     <input type="submit" class="st-button" value="Criar utilizador" id="button" name="button"> 
    </div> 

</form> 
</div> 

在當下樹犯規秀......我應該怎麼辦.. 感謝.. 雨果席爾瓦

回答

0

所以溶液簡單,我錯過了在佈局中的jQuery庫。

這裏是佈局代碼..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/reset.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/root.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/grid.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/typography.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/jquery-ui.css" /> 
    <link rel="stylesheet" type="text/css" href="/theme/style/jquery-plugin-base.css" /> 

     <script type="text/javascript" src="/theme/js/jquery.min.js"></script> 
     <script type="text/javascript" src="/theme/js/jquery-ui-1.9.1.custom.min.js"> </script> 
    <!--dynatree--> 

<script src='/dynatree/jquery/jquery.cookie.js' type="text/javascript"></script> 

<link rel='stylesheet' type='text/css' href='/dynatree/src/skin/ui.dynatree.css'> 
<script src='/dynatree/src/jquery.dynatree.js' type="text/javascript"></script> 

</head> 
<body style="background:#fff;"> 

    <!--CONTENT--> 
    <?php echo $this->layout()->content; ?> 
    <!--//CONTENT--> 

</body> 
</html>