ユーザーが編集するオプションが必要なレコードのリストがあります。これは私がこれまでに得たものです:
{% for mpt in mempassedtest %}
<!-- Modal Windows: Add Tests & Achievements -->
<div id="editTA{{mpt.id}}" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4>Edit Test & Achievement</h4>
</div>
<div class="modal-body">
<form action="{{ path('members_edit_personaldetails', {'member' :memid}) }}" method="post" {{ form_enctype(ta) }} id="editFamilyDetails" class="modaledit">
<table class="table modalform table-condensed">
<tbody>
<tr class="hidden">
<th>{{ form_label(ta.id, 'ID*', { 'attr': {'class': 'title'} }) }}</th>
<td>
{{ form_errors(ta.id) }}
{{ form_widget(ta.id, { 'attr': {'class': 'form-control'}}) }}
</td>
</tr>
<tr class="hidden">
<th>{{ form_label(ta.contact, 'Member*', { 'attr': {'class': 'title'} }) }}</th>
<td>
{{ form_errors(ta.contact) }}
{{ form_widget(ta.contact, { 'attr': {'class': 'form-control'}}) }}
</td>
</tr>
<tr>
<th>{{ form_label(ta.testDescription, 'Test*', { 'attr': {'class': 'title'} }) }}</th>
<td>
{{ form_errors(ta.testDescription) }}
{{ form_widget(ta.testDescription, { 'attr': {'class': 'form-control'}}) }}
</td>
</tr>
<tr>
<th>{{ form_label(ta.taken, 'Test Taken*', { 'attr': {'class': 'title'} }) }}</th>
<td>
{{ form_errors(ta.taken) }}
{{ form_widget(ta.taken, { 'attr': {'class': 'form-control'}}) }}
</td>
</tr>
<tr>
<th>{{ form_label(ta.result, 'Result*', { 'attr': {'class': 'title'} }) }}</th>
<td>
{{ form_errors(ta.result) }}
{{ form_widget(ta.result, { 'attr': {'class': 'form-control'}}) }}
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<input type="submit" value="Save Changes" id="savebuttonta" class="btn btn-success" />
<a href="#" class="btn btn-danger" data-dismiss="modal">Close</a>
{{ form_rest(ta) }}
</form>
</div>
</div>
</div>
</div>
{% endfor %}
そしてコントローラーにはこれがあります:
// Retrieve Passed Tests For That Member
$passedmembertests = $dm->createQuery('
SELECT mt.id, mt.taken, mt.result, mtd.test
FROM InstructorBundle:MapTests mt
LEFT JOIN InstructorBundle:MapTestDescriptions mtd WHERE mtd.id = mt.testDescription
LEFT JOIN InstructorBundle:MapCentreContacts mc WHERE mc.id = mt.contact
WHERE mc.id = :member
AND mt.result = :passed'
)->setParameters(array(
'member' => $memberint,
'passed' => '1'
));
$mempassedtest = $passedmembertests->getResult();
// Get Tests from Entity for Form use
$memberTA = $dm->getRepository('InstructorBundle:MapTests')->find($memberint);
// Generate Form to edit Tests & Achievements
$ta = $this->createForm( new TaType(), $memberTA);
ただし、レコードが取得されるたびにモーダル ウィンドウが生成されますが、フォームは表示されません。私は何が欠けていますか?
編集
これはTaType()
コードです:
<?php
// src/Acme/MembersBundle/Form/Type/TaType.php
// This is to handle forms for the Members Form
namespace Acme\MembersBundle\Form;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TaType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('id', 'integer', array('required'=>false));
$builder->add('contact','entity', array('class'=>'Acme\InstructorBundle\Entity\MapCentreContacts', 'property'=>'id'));
$builder->add('testDescription','entity', array('class'=>'Acme\InstructorBundle\Entity\MapTestDescriptions', 'property'=>'test',
'query_builder' => function(EntityRepository $br) {
return $br->createQueryBuilder('mtd')
->where('mtd.active = :active')
->setParameter('active', '1');
}));
$builder->add('taken', 'date', array('years' => range(1998, date('Y')), 'format' => 'dd-MMMM-yyyy'));
$builder->add('result', 'choice', array(
'choices' => array(
'0' => 'Failed',
'1' => 'Passed'
)
));
}
public function getName()
{
return 'ta';
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Acme\InstructorBundle\Entity\MapTests',
'csrf_protection' => false,
'csrf_field_name' => '_token',
// a unique key to help generate the secret token
'intention' => 'task_item',
));
}
}