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

Mauro19's avatar

Default value in Action Field doesn't work - Nova

I've defined a nova Action that is supposed to send an email to a client with his account data. The idea is to attach a Trix or Textarea field to the action with a default content email template and if possible with the account details already populated within the email content. This way the user will be able to customize the email before sending it.

I've tried just adding text to the field using the default() method but it doesn't seems to take effect

    /**
     * Get the fields available on the action.
     *
     * @return array
     */
    public function fields()
    {
        return [
            Textarea::make('Email content')->default('Simple text')
        ];
    }

It is not possible to use the default() method in Action Fields as in Form Fields?

And my second question would be, is there any way of passing data to the field to dynamically fill the Action field? In this method is not possible to use laravel's automatic dependency injection.

0 likes
3 replies
bobbybouwmann's avatar

You would expect that the default method would here, but I tried it myself and indeed it's not working!

The only solution I have for you are creating an issue on the nova repository to get this sorted out.

gabelbart's avatar

There has been an issue unfortunately it didn't lead to a solution.

However, i found that you can set a default value for \Laravel\Nova\Fields\Text fields at least (haven't tried others, feel free to try yourself and report here). Note the value field in the withMeta call in the example below:

Text::make(__('userMessage.field_title'), 'title')
  ->required()
  ->rules(['required', 'string', 'min:3'])
  ->withMeta([
    'value' => __('userMessage.prefix_reply', ['originalTitle' => $this->message?->title])
  ])

Please or to participate in this conversation.