Show name of a related entity in disabled text input #12906
-
PackagePanel builder Package Version3.2.66 How can we help you?In my form (using the panel builder), I have the following field: Forms\Components\TextInput::make('orderedBy.name')
->disabled()
->label(__('Ordered by'))
->hintAction(fn (Order $order) => $order->orderedBy ? Forms\Components\Actions\Action::make(__('Send mail'))
->icon('heroicon-s-at-symbol')
->url(
"mailto:{$order->orderedBy->email}",
) : null,
), where public function orderedBy(): BelongsTo
{
return $this->belongsTo(User::class);
} However, the input field is always empty. I've also tried to create a custom attribute like this: public function orderedByNameField(): Attribute
{
return Attribute::make(
get: fn() => $this->orderedBy->name,
);
} then referenced it as How can I make this work? |
Beta Was this translation helpful? Give feedback.
Answered by
leandrocfe
May 22, 2024
Replies: 1 comment 1 reply
-
Shoudn't it be a Select? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kolaente
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shoudn't it be a Select?
https://filamentphp.com/docs/3.x/forms/fields/select/#integrating-with-an-eloquent-relationship