Skip to content

What does the Laravel Nova Prefiller do? For instance; you select a product in field 1 and you want to pre-fill the price of the selected product in field 2. This is now possible 🤩

Notifications You must be signed in to change notification settings

marshmallow-packages/prefiller-field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nova prefiller field

A Laravel Nova field to prefill fields based on another field. Super Awesome!

Installation

composer require marshmallow/prefiller-field

Usage

public function fields(Request $request)
{
    return [
		BelongsTo::make('Product')->nullable()->searchable(),

		PrefillerText::make('Test', 'field_2')
                    ->sourceField('product')
                    ->sourceModel(\Marshmallow\Product\Models\Product::class)
                    ->prefillWith('name'), // This can be a field or a method on your target resource

        PrefillerCurrency::make('Test 3', 'field_3')
                    ->sourceField('product')
                    ->sourceModel(\Marshmallow\Product\Models\Product::class)
                    ->prefillWith('price')
                    ->currency('EUR')
                    ->default(0)
                    ->nullable(),
	]
}

Extra methods

I you want the prefiller to check for new values, even if the target field is already filled with content, you can call the method allowUpdatingFilledFields().

Supported

Currently we have only implemented the Text and Currency field because we needed it in a project for a customer. We will add more in the comming months. Feel free to send a pull request if you need another field for your project.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

About

What does the Laravel Nova Prefiller do? For instance; you select a product in field 1 and you want to pre-fill the price of the selected product in field 2. This is now possible 🤩

Resources

Stars

Watchers

Forks

Packages

No packages published