Finn
Best way to create a virtual/fake input?
I have the following fields:
The
parent_id
only comes up when has_parent
has been selected as a value in the type_fake
select.
So the first select should not be inserted/filled into the Model. Is there a way to define a field is a fake/virtual field which should not be saved in the eloquent model? So I can avoid the SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type_fake' in 'field list'
error.3 replies
Let Filament decrypt database value in TextInput
I got a TextInput field in a form in Filament which is a encrypted value in the database. I have the Laravel cast
encrypted
on it in my model, but Filament does not seem to decrypt the value if you edit 🤔21 replies
Disabled field through $set function not updating state
I used the Filament documentation (https://filamentphp.com/docs/3.x/forms/advanced#generating-a-slug-from-a-title) to automatically generate a slug based on a text field.
Like this:
As you can see I am disabling the slug TextInput, because I dont want users to be able to modify it as it automatically does that.
When I click on save I get an error that the slug column cannot be inserted in my database because the value is null. But it does have a value
If I remove the ->disabled() from the slug TextInput it does save fine.
4 replies
Section of fields that I can re-use over multiple resources/custom pages
I want to make a custom field like
SEOData::make()
which contains a few fields that go to a relationship of that model.
But I dont know if a custom field is the way to go, because I dont want to make a custom blade etc. It basically needs to be a reusable set of fields.
Because multiple resources have a relationship to a model called PageMeta.php
, and I want to implement those fields out of that database table into multiple resources/custom pages.
I can just copy and paste those fields over and over again, but then if I need to change it, I need to do it on multiple places which of course isn't what you want.
What's the best way to do this?6 replies
One record resource
I am currently creating a website for a customer which should be able to edit content on the website. Now I had the idea to make everything managable through Filament (it will act as a CMS like Wordpress basically) because it's such easy to use and great looking.
My original thought was: I will create a Database table called "home" which just has 1 record in it with columns such as: title, description, contact_button_text, header_image etc. which will be managable through Filament.
Once the home page loads it will get the first record out of the database and send that to the page to load the text and images etc from those variables out of the database.
Now to make it directly available without a "table view" within Filament when clicking on the resource in the menu, my thought was to make a custom navigation item which directly points to:
project.test/home-page/1/edit
this will edit record 1 because it only will have one record of course.
But sounds kinda hacky to me, which doesn't matter, but maybe someone else achieved making something like this and has better idea's on making site content managable through Filament? I would love to hear that!
I also know Filament's purpose isn't to be a CMS, but I think it would be perfect for this project.21 replies
Modify relationship data before inserting/creating
So I do have a resource, with a form with multiple text inputs.
In that form I made a fieldset that links to a relation
As you can see, in there I have 2 inputs in there. Now when I click on create in Filament, I want to modify the data from the text input.
Normally I would modify the data in the
app\Filament\Resources\MyResource\Pages\CreateMyResourcePage.php
using the mutateFormDataBeforeCreate(array $data)
method.
But in the $data of the mutateFormDataBeforeCreate method, I do not have access to the relationship properties <a:aPES_Think:493353113332219924>
So how would I modify it?3 replies
Access relationship data in mutateFormDataBeforeCreate
I have created a Repeater that goes into another model 'invoice_rows' like this:
Forms\Components\Repeater::make('invoice_rows')->label('Factuur regels')->relationship('row')
with the ->relationship('row')
function.
But in my resource Create file (CreateAdminInvoices.php) I use protected function mutateFormDataBeforeCreate(array $data)
and I want to access the form data of the relationship there as well, but that's not included in the $data variable. How do I make that accessible there as well?7 replies