#TextInput, set default value (from backend)
15 messages · Page 1 of 1 (latest)
Scope the section to 'user' relationship and then have a single field named 'name';
Please provide the code if you need more help
My code was like this
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('user.name')
I tried your way
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->relationship('user')
Neither way worked
More help please
I think, it will work in select?
Forms\Component\Select::make('name')
->relationship('User', 'name')
don't forget to add ->preload() so it will automatically list all user upon loading of the page
Yes, your way works for select.
But how about for TextInput?
it won't work in TextInput since it is text input.
Ok.
I just need a label, showing the user name in the form.
How can that be done?
Group::make([
TextInput::make('name')
])
->relationship('user')
Your code should actually do it. But you need to check if the relationships on the model is set.
Thank you