I have a contact plugin that I wrote that has your standard contact form functionality. It stores contact records in the database and provides a backend list/form view to view and manage the data as well as an export function to download your full list of contacts.
I am in the process of creating a second plugin which has a boot function that adds a new field and dropdown relation to the contact form. So far I've modified all of the front end logic to deal with this field and I've modified the list and form views in the backend to have it display there as well. It's not 100% complete but the value shows up.
The one thing I can't figure out for the life of me is how to get my newly added, fillable column to appear in the columns list when I click export. Is there any way to do this without modifying my original plugin's export model and adding it to the columns.yaml? Most of the code below was ripped directly from the documentation and works fine. I'm just including it as an example of where I'm at now.
I've tried adding the field as fillable to my RecordExport model but that didn't appear to do anything.
public function boot()
{
RecordModel::extend(function ($model) {
$model->addFillable([
'location_id'
]);
$model->belongsTo['location'] = [
'FreeMedical\Locations\Models\Location'
];
});
RecordsController::extendFormFields(function ($form, $model, $context) {
if (! $model instanceof RecordModel) {
return;
}
$form->addFields([
'location_id' => [
'label' => 'Location',
'searchable' => true
]
]);
});
RecordsController::extendListColumns(function ($list, $model) {
if (! $model instanceof RecordModel) {
return;
}
$list->addColumns([
'location_id' => [
'label' => 'Location',
'relation' => 'location',
'select' => 'name'
]
]);
});
}
Last updated