最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Filament: How to associate each input text below to the single radio button when it is selected - Stack Overflow

programmeradmin1浏览0评论

I have a radio button; for each choice I make it shows me the input text associated with the choice made on the radio button.

The code below works well; what I am looking for is to put the text input directly under the choice I made and NOT, as happens now, at the end of the entire radio button

<?php

namespace App\Livewire;

class CreateProduct extends Component implements HasForms
{
    use InteractsWithForms;

    public ?array $data = [];

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('name'),
                TextInput::make('slug'),
                TextInput::make('detail'),
                Radio::make('status')
                    ->options([
                        'draft' => 'Draft',
                        'scheduled' => 'Scheduled',
                        'published' => 'Published'
                    ])
                    ->live()
                    ->afterStateUpdated(fn(Radio $component) => $component
                        ->getContainer()
                        ->getComponent('dynamicTypeFieldsRadio')
                        ->getChildComponentContainer()
                        ->fill()),

                Grid::make(2)
                    ->schema(fn(Get $get): array => match ($get('status')) {
                        'draft' => [],
                        'scheduled' => [
                            TextInput::make('scheduled_input')
                                ->numeric()
                                ->required()
                                ->prefix('€'),
                        ],
                        'published' => [
                            TextInput::make('published_input')
                                ->required()
                        ],
                        default => [],
                    })
                    ->key('dynamicTypeFieldsRadio'),
            ])

            ->statePath('data');
    }


    public function render()
    {
        return view('livewire.create-product');
    }
}

Can someone please help me?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论