How to add a button inside a section in form?
I want to add unset button to to photo and video
Example
The case is to store temporary boolean value to update column after save in edit
Example
Forms\Components\Section::make('Photo')
->schema([
Placeholder::make('photo')
->content(fn ($record) => self::getImageContent($record) )
->visibleOn('edit')
->hidden(fn (?Advertisement $record, Forms\Get $get) =>
($record === null) || (!!$get('new_photo'))
),
Forms\Components\FileUpload::make('new_photo')
->image()
->storeFiles(false)
->moveFiles()
->imageEditor(),
Forms\Components\Button::make('unset_video')
->label('Unset Video')
->color('danger')
->action(fn () => $this->unsetVideo()),
])
->columns(2)
->collapsible()
->collapsed(),
public $unsetPhoto = false;
public $unsetVideo = false;
public function unsetPhoto()
{
$this->unsetPhoto = true;
}
public function unsetVideo()
{
$this->unsetVideo = true;
} Forms\Components\Section::make('Photo')
->schema([
Placeholder::make('photo')
->content(fn ($record) => self::getImageContent($record) )
->visibleOn('edit')
->hidden(fn (?Advertisement $record, Forms\Get $get) =>
($record === null) || (!!$get('new_photo'))
),
Forms\Components\FileUpload::make('new_photo')
->image()
->storeFiles(false)
->moveFiles()
->imageEditor(),
Forms\Components\Button::make('unset_video')
->label('Unset Video')
->color('danger')
->action(fn () => $this->unsetVideo()),
])
->columns(2)
->collapsible()
->collapsed(),
public $unsetPhoto = false;
public $unsetVideo = false;
public function unsetPhoto()
{
$this->unsetPhoto = true;
}
public function unsetVideo()
{
$this->unsetVideo = true;
}The case is to store temporary boolean value to update column after save in edit