Nechalon
03/10/2023, 12:17 PMifox
03/10/2023, 12:17 PMNechalon
03/10/2023, 12:18 PMgetFormFields
?Nechalon
03/10/2023, 12:20 PMpublic function getFormFields($object)
{
$fields = parent::getFormFields($object);
$fields = $this->getFormFieldsForRepeater($object, $fields, 'members', 'TeamMember', 'team-member');
return $fields;
}
ifox
03/10/2023, 12:22 PMphp
public function getFormFields($object) {
$fields = parent::getFormFields($object);
$fields['user_name'] = User::find($object->user_id)?->name;
return $fields
}
In the form:
@formField('input', [
'name' => 'user_name',
'label' => 'User name',
'disabled' => true
])
Nechalon
03/10/2023, 12:24 PMkalle
03/10/2023, 12:25 PMuser_name
which is appended to the model.Nechalon
03/10/2023, 1:53 PMifox
03/10/2023, 1:54 PM$indexColums
in your module controllerifox
03/10/2023, 1:54 PMjefsev
03/10/2023, 1:54 PMifox
03/10/2023, 1:54 PMNechalon
03/10/2023, 1:54 PMifox
03/10/2023, 1:56 PMgetSubmitOptions
in your module controllerifox
03/10/2023, 1:57 PMNechalon
03/10/2023, 2:07 PMprotected $indexColumns = [
'title' => [
'title' => 'Title',
'field' => 'title',
],
'User Name' => [
'title' => 'User Name',
'field' => 'user_name',
'sort' => true,
],
'User Email' => [
'title' => 'User Email',
'field' => 'user_email',
'sort' => true,
],
];
ifox
03/10/2023, 2:08 PMgetUserNameAttribute()
and getUserEmailAttribute()
in the model behind this controller?ifox
03/10/2023, 2:09 PMNechalon
03/10/2023, 2:10 PMifox
03/10/2023, 2:11 PMorder
method in the repository to order by a custom key. Without that the only thing it would know how to sort on would be the id column, since that's the only on in your modelNechalon
03/10/2023, 2:11 PMNechalon
03/10/2023, 2:11 PMifox
03/10/2023, 2:13 PMphp
public function getUserNameAttribute()
{
return User::find($this->user_id)?->name;
}
ifox
03/10/2023, 2:14 PMphp
public function getUserEmailAttribute()
{
return User::find($this->user_id)?->email;
}
ifox
03/10/2023, 2:14 PMifox
03/10/2023, 2:15 PMifox
03/10/2023, 2:16 PMsortKey
parameter to your indexColumns columns, and use that in the order function to order by itifox
03/10/2023, 2:16 PMifox
03/10/2023, 2:16 PMNechalon
03/10/2023, 2:18 PM