Problem/Motivation

Actually we have some cases of code duplication / complexity of code. That is due by Drupal core problemes exemple : We not have an real standard to identify the collection list pages of entities and we need to add "Bundle List" pages on each entities compatible with FormModeManager.

We have few problems with Files / User entities because theses entities not provide an "standard" entity form but have a multi step form specialy in File cases that can be problematic.

To avoid these problemes we DO provide an more robust more decoupled interfaces / manager to enhanced routes and add form_display parametter with new routes (IS THAT THE BETTER WAY TO USE Form modes).

Proposed resolution

Purpose an refactor on web/modules/contrib/form_mode_manager/src/Routing/FormModeManagerRouteSubscriber.php to simplify and clearify the route building / editing.

AFTER that refactor we can start to ADD UNIT test and switch to RC / STABLE release.

Comments

woprrr created an issue. See original summary.

woprrr’s picture

Title: Route alteration refector » Route alteration refactor
Status: Active » Needs review
StatusFileSize
new29.27 KB

First step of that BIG BIG refactor. That seems more clean more clear more mockable :). I need to test all usecases of module with that refactor.

I think we can optimise subscriber more !! BUT with this refactor it's a good start saddly i don't have more time ATM to continue....

woprrr’s picture

StatusFileSize
new32.55 KB

Some fixes in this patch ;)

psiegel’s picture

Hello,

I applied this patch (route_alteration_refactor-2834768-3.patch) to the dev version from Dec 09, the patch applied correctly but there seems to be an issue somewhere. I get this error when trying to view a node (even for uid 1), or when saving a node, or even when listing the nodes on the home page (promote to front). I tried to fully uninstall/ reinstall, no luck. When I uninstall the module, it works again.

Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\MissingMandatoryParametersException: "Some mandatory parameters are missing ("entity_bundle_id", "form_display") to generate a URL for route "entity.node.a_new_form_mode"." at /data/www/d8/DEV/multi01/core/lib/Drupal/Core/Routing/UrlGenerator.php line 171, referer: http://modv1.opwebs.comdev/

Best,
Pascal

woprrr’s picture

StatusFileSize
new35.29 KB

Hi @psiegel,

Glad to see you and your precious feedbacks in this BIG important issue.

I think we need to drush cr after apply patch to prevent that.

I re-roll patch to prevent few other problems in user / block_content entities.

I ve reviewed operation path but we need to view more synergies with taxonomy / contact form / comment That is special cases and we need to discuss if we solve that here or on other issue. That create few more complexity to solve compatibility with ALL compatible entities.

psiegel’s picture

Hello,

Thanks, this time its OK and I don't get the error anymore, the patch applied correctly.

I did the same test as in this comment: https://www.drupal.org/node/2833894#comment-11830186. I am not sure what is supposed to have changed but here is my feedback. BTW, I am only testing on content types for now since I am focusing exclusively on D8 and content. Users and other drupal are for a bit later.
1) is OK.
2) Is the same, this is for a later release I suppose
3) same issue
4) same issue
5) for later, I suppose
6) just the note.
7) same issue

Thanks again.

Best,
Pascal

woprrr’s picture

There is a typo in the permission in “default” -> default

Yes, fixed now.

Is it possible to split the default permission for node entity by content type and add one permission per content type (and leave the default node entity. It is not an issue since I can create a default mode for each content type content type and remove the default node entity permission but it would be "a nice to have", and avoid create a form mode just to have a default

Yes ! this feature request is verry needed now in Form Mode Manager. You can complete this issue and talk about that in #2838051: Split the default permission for entities by entity type

I tested with 2 content type: test01 and test 02. When going to /admin/content --> click on add content for test02 --> /node/add-list/form_mode_default_test02 it is showing 2 links:
1) test01 (node/add-list/form_mode_default_test02) and
2) test02 (node/add/test02/form_mode_default_test02)
I suppose the node/add-list/form_mode_default_test02 should go to the edit form directly and not show a page with the 2 links.

Yes !! That feature are possible only if previous feature developped in #2838051: Split the default permission for entities by entity type are implement. Infact if we have right to use the following bundles you can view an real listing if we have only 1 bundle available we are redirect directly in good edit_form @see \Drupal\form_mode_manager\Controller\FormModeManagerController::addPage

    // Bypass the entity/add listing if only one content type is available.
    if (1 == count($content)) {
      $bundle = array_shift($content);
      return $this->redirect("entity.add.$form_display", [
        'entity_bundle_id' => $bundle->id(),
        'form_display' => $form_display,
      ]);
    }

I create one issue to prevent possible misstakes #2838056: Filter list add page

The user admin (uid 1) gets all the tabs on the node view form, it can be a lot of tabs and a bit confusing if the edit forms have the same label (like "Edit" for all forms modes), and since I cannot remove the default permission from the Administrator role, there can be easily 10 edit tabs. It is not very important and I don't think you can do anything about it, just mentioning it.

The previous point can drastically filtered all "flood" tabs / action button. But i this we need to found an solution to provide an sort of action group that already aborded in https://www.drupal.org/node/2752467#comment-11834755 but i create an new issue dedicated for that go ==> #2838068: Local action flood limitation and #2752449: Move the "Edit as XXX" local tasks one level under the edit tab

Another nice to have functionality would be to have a weigth system that would allow to order which form is used. Example: a content type has 3 forms: (A: weight=5, B: weight=0 and C:weight=-5). User Editor has the permission on A and B, he gets the form B, not the A. The User “Siteadmin” has access to form A, B and C. he gets to Form C, User X has permission only on A, he gets A. Nice to have and would also solve the many tab issue for the UID 1.

Yes !!! That issue are important for futher version and to have an really stable version ! That already aborded by Dunebl on #2752469: Add a weight to the form modes do not hesitate to go help in that issue.

Not an issue, just a note that when a field is required and the field is not in the form, the node is still saved. This is something to pay attention to when creating mode forms and limiting access to some fields.

That is an normal feature and that show the power of Form mode and potential warning ! Architecturally the entity form are totaly differents forms and form A not have form B fields we can't verify if that field are not empty. It's verry important to adapt usage of form modes with your needed.

Small typo on the module list, the FormModeManager examples module name should be with spaces.

Fixed during merge of this issue.

For #2834195: Authoring Information and Promotions Options require Administer content permission i come with u for view that after having an stable release for this module i promise !!!

I think have respond all your questions best.

Really thank to your help / feedback on this issue !

woprrr credited DuneBL.

woprrr’s picture

  • woprrr committed 7cc8ac5 on 8.x-1.x
    Issue #2834768 by woprrr, psiegel, DuneBL: Route alteration refactor
    
woprrr’s picture

Status: Needs review » Fixed
woprrr’s picture

Issue tags: +Form-Modes, +Display modes

Just an information for follower of this issue #2838003: [META] - Form Mode Manager compatibility are created to point avances of module on each "standard" entities for more easy follow...

And Few feedback on issue queue are added i hope see you on that issues.

pianomansam’s picture

  • woprrr committed 10977cf on 8.x-1.x
    Issue #2834768 by woprrr, psiegel, DuneBL: Route alteration refactor
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.