简体   繁体   English

禁止编辑字段,但不禁止创建视图奏鸣曲包

[英]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.

相关问题 Symfony 3-Sonata管理员捆绑包-当从另一个实体添加时,configureFormFields禁用字段 - Symfony 3 - Sonata Admin Bundle - configureFormFields disable fields when added from another entity Symfony2,奏鸣曲:从奏鸣曲束生成的菜单中删除动作 - Symfony2, Sonata : Remove an action from menu generated by a sonata bundle Sonata Admin Bundle:列表视图中的可编辑建议字段 - Sonata Admin Bundle: Editable suggest field in list view 在sonata管理束集合字段的原型中,标签未被正确的值替换 - Label not replaced with correct value in prototype from sonata admin bundle collection field 奏鸣曲页面捆绑-创建页面 - Sonata Page Bundle - creating a page 奏鸣曲束可编辑日期字段 - Sonata bundle editable date field Sonata管理员捆绑包可点击字段 - Sonata Admin Bundle clickable Field Sonata Media Bundle如何启用pixlr编辑? - Sonata media bundle how to enable pixlr editing? Sonata管理员捆绑预览图像来自列表映射器中的某个实体,没有奏鸣曲媒体包 - Sonata admin bundle preview image from some entity in list mapper without sonata media bundle 在使用sonata_type_model字段在Sonata Admin Bundle中创建子实体时如何正确设置引用实体属性 - How to properly set referring entity property when creating sub entity in Sonata Admin Bundle using sonata_type_model field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM