2013-05-18 43 views
0

我使用ajax($ this-> Js-> get)选择任何dropdownlist的元素,然后填充其他下拉列表。但是,我有一个form-> create('User')的dropdownlists。所以,如果我使用form-> create(false)我的行为'编辑'不工作......另一方面,如果我使用form-> create('User')我的'ajax'不起作用。cakephp - ajax请求和操作“编辑”不同时工作

<?php echo $this->Form->create('User', array('action' => 'edit')); ?> 
<table> 
     <tr> 
      <th>PROJECT</th> 
      <th>VERSION</th> 
     </tr> 
      <tr> 
      <td> <?php 
       echo $this->Form->select('projects', array($projects), array('multiple' => false, 
        'class' => 'span2', 
        'id' => 'projectsTest')); 
       ?> 
      </td>  

      <td> 
       <?php 
       echo $this->Form->select('projectversions', array($projectversions), array('multiple' => false, 'class' => 'span2', 
        'id' => 'projectversionsTest')); 
       ?> 
      </td> 
     </tr> 
</table> 

<?php echo $this->Form->button('ALTERAR', array('type' => 'submit', 'class' => "btn btn-info pull-right")); ?> 


<?php 
$this->Js->get('#projectsTest')->event('change', $this->Js->request(array(
      'controller' => 'ProjectVersions', 
      'action' => 'getVersionsofProject' 
       ), array(
      'update' => '#projectversionsTest', 
      'async' => true, 
      'method' => 'post', 
      'dataExpression' => true, 
      'data' => $this->Js->serializeForm(array(
       'isForm' => true, 
       'inline' => true 
      )) 
))); 


echo $this->Form->end(); 
?> 

我该如何解决这个问题?

在此先感谢:)

+0

我使用的是2.3。 但我使用Js Helper在'添加'动作中做同样的事情,它的工作原理:) – Jcbo

回答

0

不应该工作吗?

echo $this->Form->create(null, array(
    'url' => array('controller' => 'users', 'action' => 'edit') 
)); 
+0

does not work :( 编辑动作的作品,但js helepr(ajax)不工作。 post'始终为空 js helper(ajax)可以工作,但他无法获得项目的id并通过邮寄发送。 – Jcbo