就像 TextType 和其他具有值 => $myValue 的默认属性的类型一样。在尝试在更新表单中更新用户的图片时,我正在尝试将数据库中用户的现有图像设置为默认值。我一直在阅读学说资产文档,但还没有运气 https://symfony.com/doc/current/components/asset.html
$form =$this->createFormBuilder($contact)
->add('picture', FileType::class, ['required'=>false, 'label' => 'Add
Profile picture (jpg file)'])
->add('firstname', TextType::class, array('attr'=>
array('value'=>'mydefaultvalue','class' => 'form-control')))
只需将值放在对象中:
$contact->setFirstname('Primo');
$form =$this->createFormBuilder($contact)
->add('picture', FileType::class, ['required'=>false, 'label' => 'Add
Profile picture (jpg file)'])
->add('firstname', TextType::class, array('attr'=>
array('value'=>'mydefaultvalue','class' => 'form-control')))