Would be great to have the field type as disable, for the cases we just want to show the value, but not allow to edit it. Or even to show it as text (not textfield)
Currentlty we need to validate IF field->name =='something" then apply the disable property, or with Jquery and look for the field and apply the property
Hi Nuno,
You mean to disable the field just on edit? - that makes a lot of sense on the case some fields are allowed for insert but not edit.
@akazorg Exactly. For example I have some fields that comes from REST Api, so the ID's and titles can not be changed, but you can view the fields/values.
Setting the property as "disable" would allow to show the value preventing that it changes.
The best would be show it as text, so that the user can't mess up the source code and enable the field.
Currently what I'm doing is validate IF the field=="some_field" then show the value as simple text, and protecting the insert in DB using the [protect_fields]
Hello, Also want the same feature (add disabled attr to field).
need your guys help, thanks a lot.
This feature does not currently exist. PRs are welcome.
excellent feature to have, I was looking for the same, no disabling fields in json options.
I was looking the same,
So I was trying this,
Overriding formField that you need
App/resourses/view/vendors/voyager/formFields/override_custom_field
In our formField we should copy, the field that we need from tcg/voyager/formFields
Add a condition for disabled like json options (for example number field)
I added this @if(isset($options->disabled)) disabled @endif
<input type="number"
class="form-control"
name="{{ $row->field }}"
type="number"
@if($row->required == 1) required @endif
@if(isset($options->disabled)) disabled @endif
step="any"
placeholder="{{ isset($options->placeholder)? old($row->field, $options->placeholder): $row->display_name }}"
value="@if(isset($dataTypeContent->{$row->field})){{ old($row->field, $dataTypeContent->{$row->field}) }}@elseif(isset($options->default)){{ old($row->field, $options->default) }}@else{{old($row->field)}}@endif">
{
"disabled": "something"
}
I was looking the same,
So I was trying this,
- Overriding formField that you need
App/resourses/view/vendors/voyager/formFields/override_custom_field
In our formField we should copy, the field that we need from tcg/voyager/formFields- Add a condition for disabled like json options (for example number field)
I added this@if(isset($options->disabled)) disabled @endif
<input type="number" class="form-control" name="{{ $row->field }}" type="number" @if($row->required == 1) required @endif @if(isset($options->disabled)) disabled @endif step="any" placeholder="{{ isset($options->placeholder)? old($row->field, $options->placeholder): $row->display_name }}" value="@if(isset($dataTypeContent->{$row->field})){{ old($row->field, $dataTypeContent->{$row->field}) }}@elseif(isset($options->default)){{ old($row->field, $options->default) }}@else{{old($row->field)}}@endif">- In our bread details options of our field
We add
{ "disabled": "something" }
Did you manage to get it to work using your method? Thanks
Yes, in Laravel 5.6 with Voyager 1.1. It is working very well

Here I added disabled option, also i changed name code for other purposes

Example

Hello,
Would be nice to have a readonly flag too. For slugified fields for example.
Cheers
@musthagon How did you manage to override it? I mean, I copied the same file, but I guess, Voyager doesn't know witch file to use. What should I do, if I want that Voyager uses my custom fieldForm and not the one that tcg provides?
Most helpful comment
Hi Nuno,
You mean to disable the field just on edit? - that makes a lot of sense on the case some fields are allowed for insert but not edit.