Problem/Motivation
The Remove from book outline button on the book outline form is labeled Delete and goes to the node delete form instead. This is due to the content entity form setting $actions['delete']
as a link rather than button, while the BookOutlineForm::actions()
method expects it to be a button.
Proposed resolution
The patch in #2516930-11: Remove from outline button goes to node/x/delete instead replaces the link to node/x/delete with a link to node/x/outline/remove, and adds a test to ensure the link is present.
Remaining tasks
@alexpott in #2516930-12: Remove from outline button goes to node/x/delete instead asked for a test that clicks on the link, to have a test that actually does the same things a user would.
User interface changes
The link to node/x/outline/remove will be restored: this matches the workflow in Drupal 7. No string changes.
API changes
Form structure is considered @internal
. Removing a node from a book no longer triggers the form validation handlers, but this is desired behavior as of #216064: Entity form "Delete" button triggers server-side + HTML5 form validation; change "Delete" button to a link.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#20 | 2516930-18.png | 72.48 KB | mohit_aghera |
#18 | 2516930-18.patch | 2.57 KB | alexpott |
#18 | 11-18-interdiff.txt | 1.64 KB | alexpott |
#18 | 2516930-18.test-only.patch | 1.08 KB | alexpott |
#16 | interdiff-2516930-11-12.txt | 684 bytes | mohit_aghera |
Comments
Comment #1
jhedstromComment #2
jhedstromComment #4
drcho CreditAttribution: drcho commentedI can confirm this issue on Drupal-8-beta-12. In addition it isn't possible to remove a node from books in the form display of the node.
Comment #5
jhedstromComment #6
coleman.sean.c CreditAttribution: coleman.sean.c as a volunteer commentedI was pointed here from #2650756: [Regression] No UI to remove nodes from books., which I've just closed as a duplicate. I took a slightly different approach, and replaced the button with a link to
node/x/outline/remove
. Here's my reasoning:$actions['delete']
in EntityForm was turned into a link as part of #216064: Entity form "Delete" button triggers server-side + HTML5 form validation; change "Delete" button to a link. The reason behind that change was that delete buttons trigger form validation, whereas the delete link does not. I think that argument applies to the 'Remove from outline' operation.entity.node.book_remove_form
route. It appears that\Drupal\book\Form\BookRemoveForm
is dead code, in the sense that it is not linked from anywhere in the UI.Of course either fix would be better than what we have currently. If you've got a counter-argument, I'd be happy to RTBC this approach instead.
Comment #7
coleman.sean.c CreditAttribution: coleman.sean.c as a volunteer commentedApologies: I've just run this through simplytest.me, and that's exactly what this patch does. Screenshots attached.
RTBC!
Comment #8
catchRe-uploading a patch, can't see another way to get it through the new bots.
Comment #9
mcjim CreditAttribution: mcjim as a volunteer commentedTested manually, works as described. Code makes sense. \o/
Comment #10
alexpott@coleman.sean.c is correct that this should be a link and not a submit button for the reasons given in #6. The
BookOutlineForm::delete()
method should be removed and we should just make a link to thebook-remove-form
.Comment #11
coleman.sean.c CreditAttribution: coleman.sean.c as a volunteer commentedAttached patch removes the delete method, and replaces the button with a link, as per @alexpott in #10.
Since the delete button is no longer part of the form,
drupalPostForm
can't be used to click it, and the test-only patch from #1 won't pass. Instead, I've usedassertLink
: Is that sufficient?Comment #13
alexpottLooking good.
It'd be good to click the link here and do the delete and confirm that this has worked. Yes this the functionality of the delete form is tested elsewhere but it would be good to have a test that actually does the same things as a user would.
Comment #14
coleman.sean.c CreditAttribution: coleman.sean.c as a volunteer commentedOkay.
I won't have time to work on this for a few weeks, so if someone wants to write that test, please feel free.
Comment #15
coleman.sean.c CreditAttribution: coleman.sean.c as a volunteer commentedComment #16
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commentedComment #18
alexpottNot sure what's happened in #16. I suspect it reverted some changes...
Here's a new patch with the
clickLink()
and an assert to make sure we've ended up on the right page. There's no point actually removing the book from the outline as that is tested elsewhere.Comment #20
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commentedTested issue by applying patch.
Looks good. Redirects to node/nid/outline/remove page.
Comment #23
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!