Can the layout system also be used with /node/add/ forms?
For example, so that in the form two fields can be placed next to each other, etc.?
Accepted answer
Comments
A simple way — use Field Group to create a container for fields
https://backdropcms.org/project/field_group
and CSS Flex оr Grid to alignment.
You can also create Fieldsets to hide rarely used fields or group fields in form, to improve the interface.
The short answer is no, you can't theme forms or change their layouts through the UI. There is a ported version of Display Suite, which has a submodule called Display Suite Forms that allows you to do that. Unfortunately there is no official release of the module, buy you can "play" with it by downloading it directly from the link above (click on "Code" > Download zip).
You can also play around with CSS and see if that helps you.
To do this programmatically, you can implement hook_form_FORM_ID_alter and modify the form array (e.g. putting some elements in different containers).
Other possible ways (untested, somewhat complex) might be to define a "form wrapper" theme with hook_theme that uses a template file, then use hook_form_FORM_ID_alter
to add a $form['#theme']
key that points at that theming function, create a preprocess function for that theme to get the variables ready for the template, and finally create a template file (tpl.php) for that wrapper that uses those variables, and place it in your theme's templates
folder. Then you can reorganize the markup in there. This is the basic approach of Display Suite (except that they do it in an abstracted way to allow you to modify any entity form that has fields).
Resources:
- https://drupalize.me/tutorial/introduction-theming-basics-drupal-7
- https://www.drupal.org/docs/7/theming/advanced
The short answer is no, you can't theme forms or change their layouts through the UI. There is a ported version of Display Suite, which has a submodule called Display Suite Forms that allows you to do that. Unfortunately there is no official release of the module, buy you can "play" with it by downloading it directly from the link above (click on "Code" > Download zip).
You can also play around with CSS and see if that helps you.
To do this programmatically, you can implement hook_form_FORM_ID_alter and modify the form array (e.g. putting some elements in different containers).
Other possible ways (untested, somewhat complex) might be to define a "form wrapper" theme with hook_theme that uses a template file, then use
hook_form_FORM_ID_alter
to add a$form['#theme']
key that points at that theming function, create a preprocess function for that theme to get the variables ready for the template, and finally create a template file (tpl.php) for that wrapper that uses those variables, and place it in your theme'stemplates
folder. Then you can reorganize the markup in there. This is the basic approach of Display Suite (except that they do it in an abstracted way to allow you to modify any entity form that has fields).Resources: