我试图将一个dynatree添加到zend表单中,我设法在我的zend项目中的正常页面中实现dynatree ..添加了html所需的代码以显示dynatree,但它仍然没有显示。 所以在我的页面中我有一个按钮来调用添加表单。 这是代码 /标签/添
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
));
}
view-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 :(得分: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>