#Settings Select form component default value in relation

12 messages · Page 1 of 1 (latest)

kindred ravine
#

When I'm viewing a resource and create a new item for its relation, it seems like the setted ->default('value') is not working.

I saw earlier that this will only work on creating and not on editing, but since I'm creating a new entry I figured something must be going wrong or misconfigured.

Select::make('status')
    ->options([
        'draft' => 'Draft',
        'reviewing' => 'Reviewing',
        'published' => 'Published',
    ])
    ->default('published')
    ->selectablePlaceholder(false),
unkempt sparrowBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

fast tide
#

Can you show how you are creating an item for the relation?

kindred ravine
#

This button redirects me to quotations/create?project_id=311 the Status is empty while having set the default value

Select::make('status')
    ->label('Status')
    ->options([
        'aangevraagd' => 'Aangevraagd',
        'in_opdracht' => 'In Opdracht',
        'vervallen' => 'Vervallen',
        'proef_geleverd' => 'Proef Geleverd',
    ])
    ->default('aangevraagd')
    ->required(),
fast tide
#

Just add your default to the form fill

kindred ravine
#

seems like it indeed

kindred ravine
# fast tide Just add your default to the form fill

I'd assume that the fillForm will not work on url actions?

        return QuotationsTable::configure($table)
            ->headerActions([
                CreateAction::make()
                    ->fillForm(
                        fn (): array => [
                            'subject' => '123',
                        ]
                    )
                    ->url(fn ($record) => QuotationResource::getUrl('create')),
            ])
            ->recordActions([
                ViewAction::make()
                    ->url(fn ($record) => QuotationResource::getUrl('view', ['record' => $record])),
            ]);
#

client doesn't like the modal approach, do you have some alternatives/ideas maybe?

kindred ravine
#

managed to get it working by filling the form via the CreateQuotation page 🙂 thanks for the quick reply tho!

random surge
#

Looks like the problem has been solved as you stated. Please mark as solved so there is no confusion 🙂