2

I'm wondering how I can change the layout of the node add form in Drupal 8. in Drupal 7 I worked with Panopoly and could overwrite the url in Page Manager and add a Panels Variant. I thought it would work the same way in Drupal 8 but in the Panels variant I cannot add the form items. Thus I get a blank page on activating the variant.

Any ideas?

  • Drupal 8 has "Form modes" which is part of the core "Display modes". I have not tried it but it might be a possibility. With what you're trying to do with Panels I know that did work in D7. It sounds like it could be a bug so you might want to check the issue queue over there. – Danny Englander May 12 '16 at 13:50
  • Thanks, Danny! Display Modes/Form Modes are awesome. Right now I do al ot of testing with Display Suite and is very handy. – andir Jun 14 '16 at 10:46
3

In drupal 8 there are new display modes. They are not only to view the node (view mode). They are also for the node add form (form mode).

For example to change the node add form of the content type article you go to:

/admin/structure/types/manage/article/form-display

Here you can select which fields you want to show and how they are formatted (field widgets). You can make more adjustments with php in form alter hooks or with twig in templates.

By default you have one form mode for each content type. You can create more if you go to the admin interface of display modes:

/admin/structure/display-modes

If you want to use different form modes for different users you can use this module:

Form mode control

Readme:

WHAT FOR ?

Form Mode Control allows you to use the form modes for any bundle / entity, per role and for edition / modification. Which means using different forms (fields, order, widgets, etc.) for different roles.

HOW TO USE IT ?

A - DEFAULT FORM MODES

1 - You must at first add form mode for content entities. Ex. : go to "www.your-site.com/admin/structure/display-modes/form/add" to add a new form mode.

2 - Activate the form mode for the related bundle of the right entity. Ex.if we want to activate a form mode named Super 2 (machine name = super_2) for an article (entity type : Node, Bundle : Article). Go to www.your-site.com/admin/structure/types/manage/article/form-display and activate it.

3 - Go to www.your-site.com/admin/people/permissions, a section named Form modes control was added for all form modes activated (and only activated), So , configure all permissions and give roles permissions to access form modes. NB, the permission Access all form modes allow you to access to all form modes linked to bundle and entity type.

4 - Then configure on the Form mode control administration page (www.your-site.com/admin/structure/display-modes/form/config-form-modes) and give for each role a default form modes for creation / edition (of course, each role must have access to the form mode). B - ACCESS DIRECTLY FORM MODES You can also use it with a simple extra query in the URL (?display=machine_name_of_the_form_mode) if the role is allowed to see it. Of course, the user must have the right permission for it. Ex. : if you want to access to super_2, go www.your-site.com/node/add/article?display=super_2.

| improve this answer | |
  • I am marking this as the right answer although I haven't tested it yet. I hope, that's ok. Right now I do a lot of testing with DS and the combination of DS and View Modes/Form Modes is very handy. – andir Jun 14 '16 at 10:48
1

Or using a the best and secure form mode system using routing with : https://www.drupal.org/project/form_mode_manager

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.