F
Filamentβ€’12mo ago
gizmojo

Fieldset with single column

There doesn't appear to be a way of overwriting a fieldset to have one column (without extending the class and overwrite the setup method). This code is defaulting to columns ['default' => 1, 'lg' => 2]
Fieldset::make()
->columnSpan(1)
->columns(['default' => 1])
Fieldset::make()
->columnSpan(1)
->columns(['default' => 1])
Solution:
Oh just needed to use lg instead of default ```php Fieldset::make() ->columnSpan(1) ->columns(['lg' => 1])...
Jump to solution
8 Replies
Dennis Koch
Dennis Kochβ€’12mo ago
So you are saying the code above doesn't work?
gizmojo
gizmojoOPβ€’12mo ago
Yes there doesn't appear to be a way of overwriting a fieldset to have only one column
Dennis Koch
Dennis Kochβ€’12mo ago
Did you try just ->columns(1)?
gizmojo
gizmojoOPβ€’12mo ago
Yeah that works on everything else apart from a fieldset.
Dennis Koch
Dennis Kochβ€’12mo ago
Weird. Sounds like a bug then In a normal form it should be columnSpan(2) though. Otherwise the fieldset is just 1 column
gizmojo
gizmojoOPβ€’12mo ago
That's to overwrite the full colspan πŸ™‚
<?php

namespace Filament\Forms\Components;

use Closure;
use Filament\Forms\Components\Contracts\CanEntangleWithSingularRelationships;
use Illuminate\Contracts\Support\Htmlable;

class Fieldset extends Component implements CanEntangleWithSingularRelationships
{
use Concerns\EntanglesStateWithSingularRelationship;

/**
* @var view-string
*/
protected string $view = 'filament-forms::components.fieldset';

final public function __construct(string | Htmlable | Closure | null $label = null)
{
$this->label($label);
}

public static function make(string | Htmlable | Closure | null $label = null): static
{
$static = app(static::class, ['label' => $label]);
$static->configure();

return $static;
}

protected function setUp(): void
{
parent::setUp();

$this->columnSpan('full');

$this->columns(2);
}
}
<?php

namespace Filament\Forms\Components;

use Closure;
use Filament\Forms\Components\Contracts\CanEntangleWithSingularRelationships;
use Illuminate\Contracts\Support\Htmlable;

class Fieldset extends Component implements CanEntangleWithSingularRelationships
{
use Concerns\EntanglesStateWithSingularRelationship;

/**
* @var view-string
*/
protected string $view = 'filament-forms::components.fieldset';

final public function __construct(string | Htmlable | Closure | null $label = null)
{
$this->label($label);
}

public static function make(string | Htmlable | Closure | null $label = null): static
{
$static = app(static::class, ['label' => $label]);
$static->configure();

return $static;
}

protected function setUp(): void
{
parent::setUp();

$this->columnSpan('full');

$this->columns(2);
}
}
Dennis Koch
Dennis Kochβ€’12mo ago
Oh, so you want a Fieldset that's half width and has 2 columns, sorry πŸ˜…
Solution
gizmojo
gizmojoβ€’12mo ago
Oh just needed to use lg instead of default
Fieldset::make()
->columnSpan(1)
->columns(['lg' => 1])
Fieldset::make()
->columnSpan(1)
->columns(['lg' => 1])
Want results from more Discord servers?
Add your server