mirror of
https://github.com/standardebooks/web.git
synced 2025-07-18 12:26:39 -04:00
Prefill ebook placeholder form with same collection data when adding to a collection
This commit is contained in:
parent
a17aad76c2
commit
e76f691724
1 changed files with 15 additions and 2 deletions
|
@ -19,8 +19,21 @@ try{
|
|||
if($isCreated){
|
||||
// We got here because an `Ebook` was successfully created.
|
||||
http_response_code(Enums\HttpCode::Created->value);
|
||||
$createdEbook = $ebook;
|
||||
$createdEbook = clone $ebook;
|
||||
|
||||
if(sizeof($ebook->CollectionMemberships) > 0){
|
||||
// If the `EbookPlaceholder` we just added is part of a collection, prefill the form with the same data to make it easier to submit series.
|
||||
unset($ebook->EbookId);
|
||||
unset($ebook->Title);
|
||||
$ebook->EbookPlaceholder->YearPublished = null;
|
||||
foreach($ebook->CollectionMemberships as $collectionMembership){
|
||||
$collectionMembership->SequenceNumber++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ebook = null;
|
||||
}
|
||||
|
||||
session_unset();
|
||||
}
|
||||
elseif($exception){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue