Skip to content

fix: Respect Schema::configureUsing() column configuration in defaultForm/defaultInfolist#19309

Merged
danharrin merged 1 commit intofilamentphp:4.xfrom
jeffersongoncalves:4.x-fix-columns-schema-configure-using
Feb 20, 2026
Merged

fix: Respect Schema::configureUsing() column configuration in defaultForm/defaultInfolist#19309
danharrin merged 1 commit intofilamentphp:4.xfrom
jeffersongoncalves:4.x-fix-columns-schema-configure-using

Conversation

@jeffersongoncalves
Copy link
Contributor

Problem

When using Schema::configureUsing() to globally set columns (e.g., columns(['lg' => 1])), the defaultForm() and defaultInfolist() methods in resource pages unconditionally override this configuration with columns(2), effectively ignoring configureUsing.

Root Cause

Execution order:

  1. Schema::make()configure() → applies configureUsing closures → columns set to ['lg' => 1]
  2. defaultForm()/defaultInfolist() → calls columns(2) unconditionally → overwrites to ['lg' => 2]

The defaultForm/defaultInfolist methods always force columns(2) without checking if columns were already configured via configureUsing.

Solution

Add a hasConfiguredColumns() method to the HasColumns trait and guard the columns() calls in default methods so they only apply when no columns have been previously configured.

Files to Modify

# Package File Change
1 schemas src/Concerns/HasColumns.php Add hasConfiguredColumns(): bool method
2 panels src/Resources/Pages/ViewRecord.php Guard columns() in defaultForm() and defaultInfolist()
3 panels src/Resources/Pages/EditRecord.php Guard columns() in defaultForm()
4 panels src/Resources/Pages/CreateRecord.php Guard columns() in defaultForm()
5 panels src/Resources/Concerns/InteractsWithRelationshipTable.php Guard columns(2) in defaultForm() and defaultInfolist()

Optional (action modals — secondary scope):

# Package File Change
6 panels src/Resources/Pages/ListRecords.php Guard columns(2) in getDefaultActionSchemaResolver()
7 panels src/Resources/Pages/EditRecord.php Guard columns(2) in getDefaultActionSchemaResolver()
8 panels src/Resources/Pages/ViewRecord.php Guard columns(2) in getDefaultActionSchemaResolver()

Files that DON'T need changes (no forced columns)

  • Auth/Pages/Login.php, Register.php, EditProfile.php, RequestPasswordReset.php
  • Pages/Tenancy/EditTenantProfile.php, RegisterTenant.php

Fix Pattern

Before:

public function defaultForm(Schema $schema): Schema
{
    return $schema
        ->columns($this->hasInlineLabels() ? 1 : 2)
        ->inlineLabel($this->hasInlineLabels())
        // ...
}

After:

public function defaultForm(Schema $schema): Schema
{
    if (! $schema->hasConfiguredColumns()) {
        $schema->columns($this->hasInlineLabels() ? 1 : 2);
    }

    return $schema
        ->inlineLabel($this->hasInlineLabels())
        // ...
}

New Method in HasColumns

public function hasConfiguredColumns(): bool
{
    return $this->columns !== null;
}

Target Branch

4.x

Backward Compatibility

100% backward compatible — default behavior (without configureUsing) remains identical since $columns is null by default, so the guard falls through and applies columns(2) as before. Only fixes the case where configureUsing sets columns and was previously being ignored.

Reproduction Steps

// In AppServiceProvider::boot()
Schemas\Schema::configureUsing(function (Schemas\Schema $schema) {
    return $schema->columns(['lg' => 1]);
});

Expected: Resource pages render with 1 column layout
Actual: Resource pages render with 2 columns (configureUsing ignored)

Enhance schema handling by checking for existing column configurations with `hasConfiguredColumns()` before setting default values. Applied changes across resources and interactions for consistent behavior.
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Feb 20, 2026
@danharrin danharrin added the bug Something isn't working label Feb 20, 2026
@danharrin danharrin added this to the v4 milestone Feb 20, 2026
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Roadmap Feb 20, 2026
@danharrin danharrin merged commit 1f45b0e into filamentphp:4.x Feb 20, 2026
24 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Roadmap Feb 20, 2026
@jeffersongoncalves jeffersongoncalves deleted the 4.x-fix-columns-schema-configure-using branch February 20, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants