简体   繁体   中英

disable field from editing but not from creating view sonata bundle

I have an application using Sonata Admin for the back-office.

If I use disabled => true it will remove the field from being editable in edit and create view.

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.

/** @var YourClass $subject */
$subject = $this->getSubject();
    
if($subject) {
   // DISABLE THE FIELD
} else {
   // ENABLE THE FIELD
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM