Quadrubo / filament-model-settings

Model specific settings for your filament project.
MIT License
14 stars 2 forks source link

[Question]: Page width #4

Closed aeq-dev closed 7 months ago

aeq-dev commented 8 months ago

What happened?

I checked ModelSettingsPage page and I found this piece of code:

 protected function getForms(): array
    {
        return [
            'form' => $this->form(
                $this->makeForm()
                    ->statePath('data')
                    ->columns(2)
                    ->inlineLabel($this->hasInlineLabels()),
            ),
        ];
    }

Why did you set columns to 2? how can we update it to fit the page width ?

How to reproduce the bug

-

Package Version

1.0.1

PHP Version

8.2

Laravel Version

10.x

Which operating systems does with happen with?

Linux

Notes

No response

Quadrubo commented 8 months ago

I just implemented this the way the core team did for the "Spatie Settings" package. I think of it as a sensible default but am of course open for discussion.

If you have a field inside the form it spans 1 column by default:

public function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\TextInput::make('test'),
        ]);
}

Now if you want to make it occupy the whole page, you can just add ->columnSpan(2) to it.

public function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\TextInput::make('test')
                ->columnSpan(2),
        ]);
}

You can then also add a Layout around it which spans 2 columns and offers a single column to the children:

public function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\Grid::make(1)
                ->schema([
                    Forms\Components\TextInput::make('test'),
                ])
                ->columnSpan(2),
        ]);
}

Let me know if this solves your issue :)

github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 7 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.