0

ダイナツリーを zend フォームに追加しようとしているのですが、自分の zend プロジェクトの通常のページにダイナツリーを実装することができました。ダイナツリーを表示するために必要なコードを html に追加しましたが、まだ表示されません。私のページには、追加フォームを呼び出すボタンがあります。ここにコードがあります /tags/add

 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>

ツリーが表示されない瞬間... どうすればいいですか.. ありがとう.. Hugo Silva

4

1 に答える 1

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>
于 2013-07-27T01:34:08.710 に答える