laravellaravel-nova

How to set a Laravel Nova field to display as readonly or protected?


Within Laravel Nova (v1.0.3), there are several methods that grant fine-grained control of the visibility of a resource field (canSee, showOnDetail, etc.). I can't find any methods that control if a field is editable. How can I display a field, but prevent the user from being able to edit it (make it readonly)?

For example, I'd like to display the "Created At" field, but I don't want the user to be able to change it.


Solution

  • This capability was added in v1.1.4 (October 1, 2018).

    Example usage:

    Text:: make('SomethingImportant')
        ->withMeta(['extraAttributes' => [
              'readonly' => true
        ]]),