![](/img/trans.png)
[英]How to make a field that is an entity as hidden in the form with SonataAdmin?
[英]sonataadmin - add form field at the begining of the ertain existing tab only if condition is true
我在不同的选项卡中有 $form 和一些字段,可以正常工作,我想在表单中添加一个字段
$this->getSubject()->getId()
如果这个条件不是 NULL
我做了什么,在定义了在所有条件下都应该可见的表单之后,我添加了这部分代码,在选项卡维度中添加字段 url(选项卡维度已经添加到之前的 formmapper 定义中):
if($this->getSubject()->getId() !== NULL){
$formMapper
->with('tab.dimension')
->add(
'url',
null,
[
'required' => false,
]
)
->end();
}
但我收到的错误是:
New tab was added automatically when you have added field or group. You should close current tab before adding new one OR add tabs before adding groups and fields.
有什么帮助吗?
像这样使用 Tab 如果你想添加分组而不是With
function。
if($this->getSubject()->getId(),== NULL) { $formMapper ->tab('dimension') ->add('url', null, [ 'required' => false; ]) ->end(); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.