我有一个带有联系人列表的表单.我想在提交后显示所选联系人值字段"名字" .我的问题是该字段出现但我无法设置好的数据,该字段始终保持为空.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('contacts', ChoiceType::class, [
'label' => 'Contact',
'placeholder' => 'Choose a contact',
'choices' => $this->getContacts(),
'mapped' => false,
])
->setMethod('POST')
;
$builder->get('contacts')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
$contactId = $event->getData();
$parentForm = $event->getForm()->getParent();
$contactEntity = $exampleEm->getrepository(Contact::class)->find($contactId);
$firstName = $contactEntity->getFirstName();
// where can I set the 'contactFirstname' data ?
$parentForm
->add('contactFirstname', TextType::class, [
'label' => 'First name',
]);
})
;
}
Run Code Online (Sandbox Code Playgroud)
如何输入正确的数据以使字段显示为预填?
编辑: 我找到了一个方法,但并不可怕:
$parentForm
->add('contactFirstname', TextType::class, [
'label' => 'First …Run Code Online (Sandbox Code Playgroud) 如何在所有网站上安装调试栏?
在管理方面我激活了debug mode,但Symfony调试条只在"模块"部分可见.
是否可以在所有网站上显示它,如运输部分?
我对composer有问题,它一直运行良好,但现在不想……
这是一个简单composer install命令的结果:
bob@SRV04:~/testdir$ composer install
Loading composer repositories with package information
Updating dependencies
Package operations: 44 installs, 0 updates, 0 removals
- Installing psr/container (1.0.0): The following exception is caused by a
lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-
fork-failed-errors for details
PHP Warning: proc_open(): fork failed - Cannot allocate memory in
phar:///bin/composer/vendor/symfony/console/Application.php on line 952
Warning: proc_open(): fork failed - Cannot allocate memory in
phar:///bin/composer/vendor/symfony/console/Application.php on line 952
[ErrorException] …Run Code Online (Sandbox Code Playgroud) 有没有办法区分2 ArrayCollection?(例如array_diff)
今天我循环第一个,检查$ it-> contains()是否匹配,但是我认为它可以重构。
composer-php ×1
diff ×1
fork ×1
memory ×1
php ×1
phpdebugbar ×1
prestashop ×1
proc-open ×1
symfony ×1
symfony-2.8 ×1
symfony-3.4 ×1