如果您只想在编辑表单中禁用字段,那么可以使用:->disabledOn('edit')
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name'),
Forms\Components\TextInput::make('slug')
->disabledOn('edit')
->required(),

如果您只想在编辑表单中隐藏字段,那么可以使用:->hiddenOn('edit')
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name'),
Forms\Components\TextInput::make('slug')
->hiddenOn('edit')
->required(),

disabledOn
和hiddenOn
方法都支持数组参数,比如我们想在编辑页面和查看页面隐藏字段,在创建页面正常显示,那么可以使用:->hiddenOn(['edit','view'])