我有一个298 216 212 205 205 1286 206 206 208 251 204 206 206 208 208 208
206 206 230 204 206 208 208 208 210 206 202 208 206 204 256 208
206 208 203 206 206 206 206 206 208 209 209 256 202 204 206 210
252 208 216 206 204 206 252 232 218 208 210 206 206 206 212 206
206 206 206 242 207 209 246 206 206 208 210 208 204 208 206 204
204 204 206 210 206 208 208 232 230 208 204 210 1287 204 238 207
207 211 205 282 202 206 212 208 206 206 204 206 206 210 232 209
205 207 207 211 205 207 209 205 205 211 250 206 208 210 278 242
206 208 204 206 208 204 208 210 206 206 206 206 206 208 204 210
206 206 208 242 206 208 206 208 208 210 210 210 202 232 205 207
209 207 211 209 207 209 212 206 232 208 210 244 204 208 255 208
204 210 206 206 206 1383 209 209 205 209 205 246 206 210 208 208
206 206 204 204 208 246 206 206 204 234 207 244 206 206 208 206
208 206 206 206 206 212 204 208 208 202 208 208 208 208 206 208
250 208 214 206 206 206 206 208 203 279 230 206 206 210 242 209
209 205 211 213 207 207 209 207 207 211 205 203 207 209 209 207
表单,其中包含许多映射到data_class CollectionType
的许多EditAnnouncementType
的集合。 Announcement.php
EditAnnouncementType I have one
Announces for each existing
EditAnnouncementType`表单。
我的问题是,更改单个公告后,执行代码. The user can open up a window to edit a single announcement, which displays the
后,其他公告文本将被编辑的公告的旧文本覆盖。但是,没有其他已编辑的特征有此问题,只有文本。
collectionType
$editForm->handleRequest($request);
EditAnnouncementType
class AnnouncementEditCollectionType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('announcements', CollectionType::class,
[
'entry_type' => EditAnnouncementType::class,
'entry_options' => ['label' => false],
'label_attr' =>
[
'class' => 'sr-only'
]
]);
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => AnnouncementManager::class
]);
}
}
控制器
class EditAnnouncementType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('save', SubmitType::class,
[
'label' => 'Save changes',
'attr' => ['class' => 'btn btn-primary submit-edit announcementEditButton']
])
->add('content', TextareaType::class,
[
'attr' =>
[
'class' => 'form-control announcement-text',
'rows' => '5',
'name' => 'content',
'maxlength' => '2000'
],
'required' => true
])
->add('category', ChoiceType::class,
[
'choices' =>
[
'info_type' => 1,
'star_type' => 2,
'alert_type' => 3,
'lightbulb_type' => 4,
'event_type' => 5,
'statement_type' => 6,
'cat_type' => 7,
'hands_type' => 8
],
'expanded' => true,
'multiple' => false,
'required' => true,
'label_attr' =>
[
'class' => 'sr-only'
]
])
// can probably ignore this part
->add('id', HiddenType::class)
->add('deleted', HiddenType::class, ['data' => false])
->add('displayed', HiddenType::class)
->add('employees', HiddenType::class)
->add('students', HiddenType::class)
->add('audience', ChoiceType::class,
[
'choices' =>
[
'Students: anybody with a student level field populated' => 'students',
'Employees: anybody with an employee ID number' => 'employees'
],
'expanded' => true,
'required' => true,
'multiple' => true
]);
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions (OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Announcement::class
]);
}
}