두 가지 형태가 있습니다. 처음에는 하나의 클라이언트를 선택하고 그에 대한 몇 가지 도메인 이름을 추가합니다. 그 다음, 내가 다음에 clik을 할 때, 각 행에 여러 도메인 이름 (이전에 추가 한 이름)이있는 두 번째 양식이 각 단어 (등록자, URL 및 설명)마다 다른 필드에 도착했습니다. 그것은 이것을 좋아하는 것 같습니다 :양식에서 여러 데이터를 가져 오는 방법은 무엇입니까?
toto.com | Directnic | www.toto.com | blablabla
toto.fr | 아프리카 | www.toto.fr | bla
toto.net | 간디 | www.toto.net | blabla
하지만이 데이터를 내 작업에 추가하여 데이터베이스에 추가하려면 마지막 행만 가져옵니다. 왜 ?
내 양식 :
<form action="<?php echo url_for('@add_domaines');?>" method="post">
<?php echo $form->renderGlobalErrors() ?>
<table class="form_add_domaines">
<thead>
<tr>
<th><?php echo $form['nom_domaine']->renderLabel()?></th>
<th><?php echo $form['compte_registar_id']->renderLabel() ?></th>
<th><?php echo $form['url']->renderLabel() ?></th>
<th><?php echo $form['remarque']->renderLabel() ?></th>
</tr>
</thead>
<tbody>
<?php
$domaines = explode("\n",$add_domaines);
for($i=0; $i<count($domaines); $i++)
{?>
<tr>
<td>
<?php
if(1==strcmp(' ', $domaines[$i]))
{
echo "<span style='color:red;'>"."<b>Warning, missing domain name.</b>"."</span>";
}
else
{
echo $domaines[$i];
}
?>
</td>
<td>
<?php echo $form['compte_registar_id']->renderError() ?>
<?php echo $form['compte_registar_id'] ?>
</td>
<td>
<?php echo $form['url']->renderError() ?>
<?php echo $form['url'] ?>
</td>
<td>
<?php echo $form['remarque']->renderError() ?>
<?php echo $form['remarque'] ?>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<td>
<?php echo link_to(__('Back', array(), 'sf_admin'), '@domaine_new') ?>
</td>
<td>
<?php echo $form->renderHiddenFields(false) ?>
<input type="submit" class="submit" value="Add" />
</td>
</tr>
</tfoot>
</table>
</form>
내 조치 : 내 양식의
[...]
$this->form = new AddDomainesForm();
$this->form->setDefault('client_id', $idClient);
$this->form->setDefault('nom_domaine', $noms_domaine);
if($request->isMethod('post'))
{
$name = $this->form->getName();
$values = $request->getParameter($name);
$files = $request->getFiles($name);
$this->form->bind($values, $files);
if($this->form->isValid())
{
print_r($values);break;
//$this->form->save();
$this->getUser()->setFlash('notice', 'OK.');
$this->redirect('@domaine');
}
}
print_r($values)
반환 마지막 행
배열 ([compte_registar_id] => 1 [URL] => www.toto.net [remarque] => blabla [nom_domaine] => toto.com toto.fr toto.net [client_id] => 17 [_csrf_token] => ...)
고맙습니다!
내게 양식 HTML, plz –
추가했습니다. 제발 좀 봐주세요 :) –
당신은 다른 하나 (예 : sfFrom)에 'AddDomainesForm'을 삽입해야한다고 생각합니다. 문서의 [여기] (http://symfony.com/legacy/doc/more-with-symfony/1_4/en/06-Advanced-Forms)에 설명되어 있습니다. – 1ed