Easyadmin 3 字段 disabled/read-only

Easyadmin 3 field disabled/read-only

是否有机会使用 EasyAdmin 的实现字段对用户禁用字段?

我想向用户显示一个布尔值“isPaid”,但我不想让他更改它,只是向他显示(支付网关这样做)

感谢您的帮助!

您可以customize the template used to render each property, but I guess you should use this with Security Voters确保用户无法更改表单以强制和提交被黑数据。

您可能正在寻找的是:

BooleanField::new('isPaid')->setFormTypeOption('disabled','disabled');

其实我所需要和想要的是:

public function configureFields(string $pageName): iterable
{
    ...
    $isPaid = BooleanField::new('isPaid')->renderAsSwitch(false)->hideOnForm();
    ...
}

谢谢你的帮助!