0
我想在jQuery ajax中添加一個新的ZF2'Zend \ Form \ Element。但是,當我使用Zend表格時,我不知道如何製作它。這是add.phtml文件。如何在jQuery中添加新的ZF2'Zend Form Element ajax
<script type="text/javascript">
$(document).ready(function(){
$(".pid").change(function(){
var id = $('.pid').val();
var $_this = $(this);
$.ajax({
type:"POST",
url:"<?php echo $this->url('Element/default',array('action'=>'change'));?>",
data:"pid="+id,
dataType:'json',
async:false,
success:function(data){
if(data.response){
//here I want to add a new select component after select conponent "pid" using like "$this->formRow($form->get('mid'))" or else .
}
}
});
});
});
</script>
以下是html的其餘部分。
<?php
$title = 'add';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<?php
$form = $this->form;
$form->setAttribute('action', $this->url(
'Element/default',
array(
'action' => 'add'
)
));
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formRow($form->get('pid'));
echo $this->formRow($form->get('name'));
echo $this->formRow($form->get('desc'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();
如何在jquery ajax中添加新的zend表單元素?謝謝。
對不起我很懶,但它內的所有解釋在這裏:http://www.michaelgallego.fr/blog/2012/07/ 04/new-zendform-features-explained/ – Sam
我未能打開網站.. – Leo
也許這將有助於:http://framework.zend.com/manual/2.0/en/modules/zend.form.collections.html #添加新元素 - 動態 – Andy0708