PHP 템플릿에 여러 개의 폼이 있고, 다른 ID를주고 싶습니다. 그래서 js를 사용하여 폼을 제출할 수 있습니다. PHP 템플릿을 찾을 수 없다면 어떻게 할 수 있습니까?PHP 템플리트를 사용하여 symfony2에서 양식 id 속성을 변경하는 방법은 무엇입니까?
이이 JS와 onclick을 표시 편집 형태 :
function qytetShowEditForm(idNumber, cityName)
{
//check if there's another edit form active
if(document.getElementById("qytete_table").edit)
return;
<?php $string = $view['form']->start($edit_form).
"<td style=\"text-align: center;\"></td><td style=\"text-align: center;\">".
$view['form']->widget($edit_form['emri']).
"</td>
<td style=\"max-width: 150px; text-align: center;\">".
$view['form']->widget($edit_form['foto']).
"</td>
<td style=\"text-align: center;\">
<a onclick=\"qytetEditSubmit();\" id=\"ndrysho\" style=\"cursor: pointer; padding: 7px 12px 7px 12px; border-radius: 4px; color: white; background-color: orange;\">Ndrysho</a>
</td>".
$view['form']->end($edit_form);
$string = str_replace(array("\r\n", "\r", "\n"), "", $string);
?>
document.getElementById("row_"+idNumber).innerHTML = '<?php print($string);?>';
var edit_emri = document.getElementsByClassName('cl_emri_edit');
edit_emri[0].placeholder = cityName;
document.getElementById("qytete_table").edit = true;
}
이 항상 같이 추가하여 양식 : 내 템플릿에
public function showAction()
{
//get all from db
$em = $this->getDoctrine()->getManager();
$qytete = $em->getRepository('EraRestoranteBundle:Qytet')->findAllOrderedByName();
$qytet = new Qytet();
//create add form
$add_form = $this->createFormBuilder($qytet)
->setAction($this->generateUrl('admin_initconfig_qytet_create'))
->setMethod('POST')
->add('emri', 'text', array('attr' => array('class' => '', 'size' => '12')))
->add('foto', 'file', array('required' => false, 'attr' => array('class' => '', 'style' => 'max-width: 150px;')))
->add('shto', 'submit', array('attr' => array('class' => '', 'style' => 'padding: 7px 20px 7px 20px; border: none; border-radius: 4px; color: white; background-color: rgb(197, 213, 43);')))
->getForm();
//create edit form
$edit_form = $this->createFormBuilder($qytet)
->setAction($this->generateUrl('admin_initconfig_qytet_update'))
->setMethod('POST')
->add('emri', 'text', array('attr' => array('class' => 'cl_emri_edit', 'size' => '12')))
->add('foto', 'file', array('required' => false, 'attr' => array('class' => 'cl_foto_edit', 'style' => 'max-width: 150px;')))
->getForm();
//render template
return $this->render('EraAdminBundle:InitConfig:qytet.html.php', array('qytete'=>$qytete, 'add_form'=>$add_form->createView(), 'edit_form'=>$edit_form->createView()));
}
: 내 컨트롤러에서
<?php echo $view['form']->start($add_form) ?>
<td></td>
<td style="text-align: center;">
<?php echo $view['form']->widget($add_form['emri']) ?>
</td>
<td style="max-width: 150px; text-align: center;">
<?php echo $view['form']->widget($add_form['foto']) ?>
</td>
<td style="text-align: center;">
<?php echo $view['form']->widget($add_form['shto']) ?>
</td>
<?php echo $view['form']->end($add_form); ?>
나는이 같은 JS와 편집 양식을 제출할 수 있도록하려면 : 당신을 만들어
function qytetEditSubmit()
{
var submit = confirm("Doni t'i ruani ndryshimet?");
if(submit)
{
//document.getElementById().submit();
}
else
window.location.assign("<?php echo $view['router']->generate('admin_initconfig');?>");
}
관련 코드를 게시 할 수 있다면 도움이 될 것입니다. – srquinn
질문을 편집했습니다 ... – user3080603