Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mhebs's avatar
Level 1

Custom Text for confirmation Undefined method confirmText()

Hello, I'm trying to follow the docs and adding custom text to my action confirmation. https://nova.laravel.com/docs/2.0/actions/defining-actions.html#action-modal-customization

when I try to add it like that

    /**
 * Get the actions available for the resource.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return array
 */
public function actions(Request $request)
{
    return array(
        (new MakeSalesReceiptFromTransaction)->confirmText('dsasa')
    );
}

I get undefined function confirmText()

Is there a class I'm supposed to be importing or something?

0 likes
9 replies
jlrdw's avatar

In the docs example: quote

public function actions(Request $request)
{
    return [
        (new Actions\ActivateUser)
            ->confirmText('Are you sure you want to activate this user?')
            ->confirmButtonText('Activate')
            ->cancelButtonText("Don't activate"),
    ];
}

endquote

You are probably missing this line:

 (new Actions\ActivateUser)

Study the example again.

mhebs's avatar
Level 1

Thanks for the help, but nova can't find the class Actions\ActivateUser phpStorm can't find it either to import.

piljac1's avatar

A resource uses the App\Nova namespace, while actions use the App\Nova\Actions namespace. You have to specify it when creating a new instance of your action.

new Actions\MakeSalesReceiptFromTransaction

Alternatively, you can keep your code as is and use the following at the top of your resource file :

use App\Nova\Actions\MakeSalesReceiptFromTransaction;

But I wouldn't recommend the second option because it can get messy if you use multiple actions in your resource.

mhebs's avatar
Level 1

return [ (new Actions\MakeSalesReceiptFromTransaction)->confirmText("dsda"), ];

still doesn't offer me the methods.

piljac1's avatar

Can you post your MakeSalesReceiptFromTransaction.php file content ?

mhebs's avatar
Level 1

namespace App\Nova\Actions;

use App\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\ActionFields;
use App\Services\QuickbooksService;

class MakeSalesReceiptFromTransaction extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;


    /**
     * 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)
    {


        return Action::message("testing");

    }

    /**
     * Get the fields available on the action.
     *
     * @return array
     */
    public function fields()
    {
        return [];
    }
}
piljac1's avatar

Did you try to output the content of new Actions\MakeSalesReceiptFromTransaction ?

mhebs's avatar
Level 1

Hello, I dumped MakeSalesReceiptFromTransactions and this is what it printed.

MakeSalesReceiptFromTransaction {#645 ▼
  +name: null
  +component: "confirm-action-modal"
  +withoutActionEvents: false
  +availableForEntireResource: false
  +withoutConfirmation: false
  +onlyOnIndex: false
  +onlyOnDetail: false
  +batchId: null
  +runCallback: null
  +meta: []
  +seeCallback: null
  #job: null
  +connection: null
  +queue: null
  +chainConnection: null
  +chainQueue: null
  +delay: null
  +middleware: []
  +chained: []
}

Please or to participate in this conversation.