Start your All-Access Pass to unlock this challenge
How could we set the readonly HTML attribute to true for the slug text field on all pages except for the "new" page?
readonly
true
slug
yield Field::new('slug') ->setFormTypeOption('attr', [ 'readonly' => $pageName !== 'new', ]);
Both C and A are valid
yield TextField::new('slug') ->setFormTypeOptions([ 'attr' => [ 'readonly' => $pageName !== 'new', ], ]);
yield Field::new('slug') ->setCustomOptions([ 'attr' => [ 'readonly' => $pageName !== 'new', ], ]);