upline/fill-button

Button to fill other fields in Laravel Nova resource form

1.0.1 2022-04-29 16:34 UTC

This package is auto-updated.

Last update: 2024-04-29 05:05:52 UTC


README

Button for filling some form fields using values of other fields in laravel nova resource forms.

Example

use Upline\FillButton;

FillButton::make('Fill total fields', 'fill-prices')
    ->setFillFunction(function ($data) {
        return [
            'total' => $data['price'] + $data['quantity'],
            'totalDiscount' => $data['discount'] + $data['quantity'],
        ];
    })
    ->setSourceFields(['price', 'discount', 'quantity'])

Explanation

->setSourceFields($fields) method sets fields that will be watched for changes, and will be sent on the button click.

->setFillFunction(...) method sets a function that will be called to calculate values to fill the fields.

To be done

  • Add image/video of component to readme
  • Test on nova 4
  • Add tests