Open majdghithan opened 9 months ago
It depends if the button needs to be set in a static or variable condition.
You can start by adding a computed field to FormField.vue:
FormField.vue
computed: { disableButton() { return this.currentField.disableButton || false; }, // ... }
Add a v-if to the last <component> in FormField.vue at the bottom:
v-if
<component>
<component v-if="!disableButton" :layouts="layouts" :is="currentField.menu.component" // ... @addGroup="addGroup($event)" />
And last, add meta to the field by adding a method to the Whitecube\NovaFlexibleContent\Flexible's to fill disableButton:
Whitecube\NovaFlexibleContent\Flexible
disableButton
namespace Whitecube\NovaFlexibleContent; // .. class Flexible extends Field { use SupportsDependentFields; /** * Disable button * * @return mixed */ public function disableButton($disable) { $disabled = false; if(is_bool($disable)) { $disabled = $disable; } if(is_callable($disable)) { $disabled = $disable(); } $this->withMeta(['disableButton' => $disabled]); return $this; } }
Use this method like all other public methods to control the field.
Flexible::make('Flexible') ->addLayout(SomeLayout::class) ->resolver(SomeResolver::class) ->disableButton(true);
Or use a function
->disableButton(function() use ($whatever) { return $whatever === 'something-to-disable' ? true : false; });
Not tested, should work though.
If it needs to be rendered from javascript's point of view, I'm not going to give you a quick example out of the top my head because that is not as simple as the above, but possible.
It depends if the button needs to be set in a static or variable condition.
You can start by adding a computed field to
FormField.vue
:Add a
v-if
to the last<component>
inFormField.vue
at the bottom:And last, add meta to the field by adding a method to the
Whitecube\NovaFlexibleContent\Flexible
's to filldisableButton
:Use this method like all other public methods to control the field.
Or use a function
Not tested, should work though.
If it needs to be rendered from javascript's point of view, I'm not going to give you a quick example out of the top my head because that is not as simple as the above, but possible.