Add "onlyWhenCreating" and "onlyWhenUpdating" field visibility #3225
FrittenKeeZ
started this conversation in
General
Replies: 1 comment
-
Clean solution, extended to include closures: class NovaServiceProvider extends ServiceProvider
{
...
public function boot()
Field::macro('onlyWhenCreating', function (\Closure $closure = null) {
$this->showOnIndex = false;
$this->showOnDetail = false;
$this->showOnCreation = $closure ? $closure() : true;
$this->showOnUpdate = false;
return $this;
});
Field::macro('onlyWhenUpdating', function (\Closure $closure = null) {
$this->showOnIndex = false;
$this->showOnDetail = false;
$this->showOnCreation = false;
$this->showOnUpdate = $closure ? $closure() : true;
return $this;
});
}
...
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If you have fields you only want shown when creating or updating, you currently have to call
onlyOnForms
and eitherhideWhenCreating
orhideWhenUpdating
- it would be convenient if you only need to call one method.It's easy to add the last two methods as macros in
NovaServiceProvider
:Beta Was this translation helpful? Give feedback.
All reactions