Fixes #4274 -- Add podcast storage location select to station form.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-06-10 15:32:11 -05:00
parent 462759b122
commit db8bc3dbb1
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
2 changed files with 31 additions and 0 deletions

View File

@ -653,6 +653,15 @@ return [
],
],
'podcasts_storage_location_id' => [
'select',
[
'label' => __('Podcasts Storage Location'),
'choices' => [],
'form_group_class' => 'col-md-6',
],
],
'is_enabled' => [
'toggle',
[

View File

@ -86,6 +86,7 @@ class StationForm extends EntityForm
$recordArray = $this->normalizeRecord($record);
$recordArray['media_storage_location_id'] = $recordArray['media_storage_location']['id'] ?? null;
$recordArray['recordings_storage_location_id'] = $recordArray['recordings_storage_location']['id'] ?? null;
$recordArray['podcasts_storage_location_id'] = $recordArray['podcasts_storage_location']['id'] ?? null;
$this->populate($recordArray);
}
@ -121,6 +122,19 @@ class StationForm extends EntityForm
)
);
}
if ($this->hasField('podcasts_storage_location_id')) {
$recordingsStorageField = $this->getField('podcasts_storage_location_id');
$recordingsStorageField->setOption('description', $storageLocationsDesc);
$recordingsStorageField->setOption(
'choices',
$this->storageLocationRepo->fetchSelectByType(
Entity\StorageLocation::TYPE_STATION_PODCASTS,
$create_mode,
__('Create a new storage location based on the base directory.'),
)
);
}
}
if ('POST' === $request->getMethod() && $this->isValid($request->getParsedBody())) {
@ -146,6 +160,14 @@ class StationForm extends EntityForm
)
);
}
if (!empty($data['podcasts_storage_location_id'])) {
$record->setPodcastsStorageLocation(
$this->storageLocationRepo->findByType(
Entity\StorageLocation::TYPE_STATION_PODCASTS,
$data['podcasts_storage_location_id']
)
);
}
}
$errors = $this->validator->validate($record);