F
Filament3mo ago
Damien

Styling forms modal forms created with createOptionsForm()

I have a modal for creating contacts, if a company does not exist, I want to be able to create on on the fly so I am using createOptionsForm() to create it in situ. I am trying to styling it rather simply but I am struggling to get it to work correctly and I am unsure if it is possible or if I am barking up the wrong tree. I have attached a screenshot and the code is below:
Select::make('company_id')
->relationship('company', 'name')
->searchable()
->preload()
->placeholder('Select a company')
->columns(12)
->createOptionForm([
TextInput::make('name')
->required()
->maxLength(255)
->columnSpan(12)
->label('Company Name'),
TextInput::make('addr_line_1')
->columnSpan(2)
->required()
->columnSpan(6)
->maxLength(255),
TextInput::make('addr_line_2')
->columnSpan(6)
->maxLength(255),
//....
]),
Select::make('company_id')
->relationship('company', 'name')
->searchable()
->preload()
->placeholder('Select a company')
->columns(12)
->createOptionForm([
TextInput::make('name')
->required()
->maxLength(255)
->columnSpan(12)
->label('Company Name'),
TextInput::make('addr_line_1')
->columnSpan(2)
->required()
->columnSpan(6)
->maxLength(255),
TextInput::make('addr_line_2')
->columnSpan(6)
->maxLength(255),
//....
]),
I removed some of the inputs to keep it short.
No description
7 Replies
Vp
Vp3mo ago
What is the exact problem?
I am unsure if it is possible or if I am barking up the wrong tree.
It's possible, the easiest way to check/make it working is copy paste all the form needed to create new Company, for example: Your CompanyResource Form and Your select "+" company form should match (not design, but data) And they should've BelongsTo relationship
toeknee
toeknee3mo ago
try changing: ->columnSpan(12) to ->columnSpanFull() And also.. you have two column spaces on your addr_line_1 it's either 6 or 2 😉
Damien
Damien3mo ago
And also.. you have two column spaces on your addr_line_1 it's either 6 or 2 😉
Classic! Will give this a go apologies that this wasn't clear, it was that the columns do not seem to be applying the specified columns correctly. Going to try the below suggestions and come back to here. Hmm, I copied and pasted the form from the original resource, didn't make a difference. I also tried using columnSpanFull() which also did not seem to make a difference.
Vp
Vp3mo ago
like this
->createOptionForm([
Forms\Components\Grid::make()
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255)
->columnSpanFull()
->label('Company Name'),
Forms\Components\TextInput::make('addr_line_1')
->required()
->maxLength(255),
Forms\Components\TextInput::make('addr_line_2')
->maxLength(255),
// ...
]),
]),
->createOptionForm([
Forms\Components\Grid::make()
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255)
->columnSpanFull()
->label('Company Name'),
Forms\Components\TextInput::make('addr_line_1')
->required()
->maxLength(255),
Forms\Components\TextInput::make('addr_line_2')
->maxLength(255),
// ...
]),
]),
toeknee
toeknee3mo ago
As Vp said, but also your columns won't apply properly when you have:
TextInput::make('addr_line_1')
->columnSpan(2)
->required()
->columnSpan(6)
->maxLength(255),
TextInput::make('addr_line_1')
->columnSpan(2)
->required()
->columnSpan(6)
->maxLength(255),
You have two columnSpans here.
Damien
Damien3mo ago
Ah I was missing the Grid, I did remove the duplicate columnSpan however, thank you both! Will try it now. That worked thanks, the Grid was the missing key!
Want results from more Discord servers?
Add your server
More Posts
How to create a website and have the filamentphp as SASS product?Hi guys, I'd like to create a website with **statamic cms** (laravel) and also give access to filameUnable to set checkbox default value to trueI have this but it's unchecked: ```php Forms\Components\Checkbox::make('is_admin') ->inline(trueSection with reactive fields forces collapse after field value changes.I have a use case where I would want the heading of Section to reflect values of fields under it. ThTable with a modal action that should contain a custom table-like form, is that even possible?I have a table showing users, with an Action that opens a modal. I want the modal to contain a list Admin PanelIf the Admin is logged in currently in a session and the super admin Deactivates the admin's accountIs it possible for filament that I will show all the data in different panel? my foreign key is id.The Accruals table will also be shown in Draft Bill table , the foreign id is the reference number.How can i change this default text into popup Relationship?Hi! someone can help me? I did'nt find this into the documentation how to change this text (yelow) wHow can i remove this default label text in resourceHow can i remove this default label text in resourceRepeater Duplicate queries when adding new itemMy question is the following, why? when you add a new item to the repeater it executes the ->visibleImplementing Role-Based Access Control for Custom Pages on FilamentHello! How are you? I'm trying to define a specific middleware to access a custom page on Filament.