laravel / nova-issues

554 stars 34 forks source link

Can't use fields on Actions #2671

Closed Johnathan closed 4 years ago

Johnathan commented 4 years ago

Description:

When I try to trigger a Nova action that have fields I get a console error

vendor.js?id=f9725df909a5af18907e:1 TypeError: e.fill is not a function
    at app.js?id=587ceb744944d21f5cff:1
    at $e (vendor.js?id=f9725df909a5af18907e:1)
    at Function.Xa (vendor.js?id=f9725df909a5af18907e:1)
    at app.js?id=587ceb744944d21f5cff:1
    at Function.pr.tap (vendor.js?id=f9725df909a5af18907e:1)
    at actionFormData (app.js?id=587ceb744944d21f5cff:1)
    at a.executeAction (app.js?id=587ceb744944d21f5cff:1)
    at a.determineActionStrategy (app.js?id=587ceb744944d21f5cff:1)
    at a.handleSelectionChange (app.js?id=587ceb744944d21f5cff:1)
    at It (vendor.js?id=f9725df909a5af18907e:1)

Steps To Reproduce:

<?php

namespace App\Nova\Actions;

use App\Fixture;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;

class UpdateResult extends Action
{
    use InteractsWithQueue, Queueable;

    /**
     * Perform the action on the given models.
     *
     * @param  \Laravel\Nova\Fields\ActionFields  $fields
     * @param  \Illuminate\Support\Collection  $models
     * @return mixed
     */
    public function handle(ActionFields $fields, Collection $models)
    {
//        $models->each(function(Fixture $fixture){
//            $fixture->updateScore();
//        });

        return Action::message('Fixture result has been updated');
    }

    /**
     * Get the fields available on the action.
     *
     * @return array
     */
    public function fields()
    {
        return [
            Text::make('Test'),
        ];
    }
}

That's it. I have an action that works already that doesn't make use of fields, but as soon as I added one, just to test I got the same error.

Johnathan commented 4 years ago

Just realised it's because I'm adding the action with ->withoutConfirmation(). So I guess this can be closed.

jankapusta commented 3 years ago

I had same problem, JS error - then i made public $withoutConfirmation = false;

Andrewrafat commented 5 months ago

where to write this public $withoutConfirmation = false @jankapusta

maul75 commented 5 months ago

where to write this public $withoutConfirmation = false @jankapusta

On your action class ...

Andrewrafat commented 5 months ago

@maul75 i did that aslo same problem