[英]disable field from editing but not from creating view sonata bundle
I have an application using Sonata Admin for the back-office.我有一个使用 Sonata Admin 作为后台的应用程序。
If I use disabled => true
it will remove the field from being editable in edit and create view.如果我使用
disabled => true
,它将删除该字段在编辑和创建视图中不可编辑。
Is there a way to disable it only on the edit screen?有没有办法只在编辑屏幕上禁用它?
I think you should try the following code to get the subject of the Admin and check if subject exist then disable the field.我认为您应该尝试以下代码来获取管理员的主题并检查主题是否存在然后禁用该字段。 Update your
configureFormFields
method inside admin.在 admin 中更新您的
configureFormFields
方法。
/** @var YourClass $subject */
$subject = $this->getSubject();
if($subject) {
// DISABLE THE FIELD
} else {
// ENABLE THE FIELD
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.