is there any chance to disable an field to user using EasyAdmin's implemented fields?
I would like to show to user a boolean value of "isPaid", but i don't want him to change it, just show him (the payment gateway does this)
Thanks for your help!
Configuring EasyAdmin Configuration of EasyAdmin is done via convars, these can be set via your server config file or by typing it as a command inside your servers' console (this method may not always work with EasyAdmin and the settings will reset after the server has been restarted.
Fields allow to display the contents of your Doctrine entities on each CRUD page. EasyAdmin provides built-in fields to display all the common data types, but you can also create your own fields. If your CRUD controller extends from the AbstractCrudController provided by EasyAdmin, the fields are configured automatically.
If you need a better control of the design depending on the device width, you can pass a string with the responsive CSS classes that define the width of the field on different breakpoints: This example adds col-sm-6 to override the default EasyAdmin behavior and display the two fields on the same row also in the sm breakpoint.
If you need even greater control, consider using the following way of defining the fields using PHP generators: By default, EasyAdmin displays one form field per row. Inside the row, each field type uses a different default width (e.g. integer fields are narrow and code editor fields are very wide).
What you are probably looking for is this:
BooleanField::new('isPaid')->setFormTypeOption('disabled','disabled');
Actually all i needed and wanted is this:
public function configureFields(string $pageName): iterable
{
...
$isPaid = BooleanField::new('isPaid')->renderAsSwitch(false)->hideOnForm();
...
}
Thanks for your help anyway!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With