Amitoj
Amitoj
FFilament
Created by Amitoj on 8/31/2024 in #❓┊help
url() is disrupting table columns
Hi folks, I am using table columns with combination of Split & Stack. Everything from layout perspective looks fine until I place url() in any of the columns. I have attached 3 scenarios to demonstrate the issue 1. In 1st picture I am not using url() anywhere and the layout looks what I expect it to be. 2. In 2nd picture, I wanted to insert url() on username, but it disrupt the columns before it. 3. In 3rd picture, I moved the url() function to the image for testing, and it still disrupted the columns before it. I am pretty sure I must missing some parameters in my table builder that is leading to this unexpected behaviour, although I tried all the combinations of breakpoints and canGrow() functionalities, but I didnt seem to fix it. Can someone please tell me if it is filament bug or I am missing something? Thanks!
3 replies
FFilament
Created by Amitoj on 5/28/2024 in #❓┊help
HasOne relationship not updating foreignKey in parent model
Hi there, I have two models, Project & ProjectAttachment. The relation in Project model is:
protected $fillable = [
...
'attachment_id',
...
]
public function attachment(): HasOne{
return $this->hasOne(ProjectAttachment::class, foreignKey: 'id', localKey: 'attachment_id');
}
protected $fillable = [
...
'attachment_id',
...
]
public function attachment(): HasOne{
return $this->hasOne(ProjectAttachment::class, foreignKey: 'id', localKey: 'attachment_id');
}
and in ProjectResource class, I am using
Section::make('Attachment')
->relationship('attachment')
->columns(2)
->schema([
Select::make('type')
->options(ProjectAttachmentType::options())
->native(false)
->reactive()
->required(),
TextInput::make('url')
->label('URL')
->url()
])
Section::make('Attachment')
->relationship('attachment')
->columns(2)
->schema([
Select::make('type')
->options(ProjectAttachmentType::options())
->native(false)
->reactive()
->required(),
TextInput::make('url')
->label('URL')
->url()
])
Although I was very confident it will work, this is only adding rows in ProjectAttachment table and not updating the attachment_id in Project table when submitting a create record request, resulting into empty columns in Attachment section above. But if I add attachment_id manually in database, it would fill up the columns in Attachment. Can someone please help with if I missed anything?
9 replies
FFilament
Created by Amitoj on 4/10/2024 in #❓┊help
Distorted Menu Button & Modals
No description
26 replies
FFilament
Created by Amitoj on 10/5/2023 in #❓┊help
How to get search record after choosing SELECT option?
Hi there, I am using the following code to obtain user_id (which belongs to user model). I am trying to forward the search record of selected user to another fields (i.e. phone_number) without using manual search query. Is there anyway that filaments provide to do the work, I failed to find related content on the documentation, thank you.
Select::make('user_id')
->label('Customer Email')
->relationship(name: 'user', titleAttribute: 'email')
->searchable()
->preload()
->required()

->afterStateUpdated(function (Set $set) {
$set('phone_number', 'Get customer phone number here');
}),
TextInput::make('phone_number')
->maxLength(50)
->required()
Select::make('user_id')
->label('Customer Email')
->relationship(name: 'user', titleAttribute: 'email')
->searchable()
->preload()
->required()

->afterStateUpdated(function (Set $set) {
$set('phone_number', 'Get customer phone number here');
}),
TextInput::make('phone_number')
->maxLength(50)
->required()
4 replies