Skip to content
Snippets Groups Projects
Commit 1a4b945f authored by Chris Burgess's avatar Chris Burgess
Browse files

Issue #3285713: Docs tidy

parent 7ea1df25
No related branches found
Tags 8.x-1.0-rc1
1 merge request!8Issue #3285713: Docs tidy
Pipeline #20410 passed
ADVANCED FORM
===============================================================================
# ADVANCED FORM
A UI tweak to /hide/ certain features or the form interface from normal use,
but still have them available on the page for validation and quick access.
This slims down the UI to make things seem simpler, without overloading the
maintenance tasks with layers of permissions, or removing any control from the
user.
maintenance tasks with layers of permissions, or removing any control from
the user.
## USAGE
USAGE
-------------------------------------------------------------------------------
When enabled, any configured form can have elements hidden (by css) for
normal use, and a small client-side button [Advanced] can be pressed to reveal
the rest of the form as needed.
CONFIGURATION
-------------------------------------------------------------------------------
The syntax for defining which form elements are 'hidden' is based entirely on
css selectors, with some shortcuts.
node-form:[#revision-information]
- will hide the revision information fieldset on node forms.
block-admin-configure:[#user-specific-visibility-settings]
- will remove a seldom-used option from block admin pages.
## CONFIGURATION
Use firebug or similar to find the correct selectors to choose your target form
elements.
The syntax for defining which form elements are 'hidden' is based entirely
on css selectors, with some shortcuts.
A number of additional css classes are inserted into the form element for
additional, specific control.
Taxonomy terms selected on node forms are also set as context classes, so it's
possible to define rules that only apply when a certain term is selected in the
form.
More instructions are on the config page, which can be found at
'admin/config/user-interface/advancedform'
- `node-form:[#revision-information]` will hide the revision information fieldset on node forms.
- `block-admin-configure:[#user-specific-visibility-settings]` will remove a seldom-used option from block admin pages.
To debug the css or see how it works, look at the path '/advancedform_css'
A number of additional css classes are inserted into the form element for
additional, specific control.
SEE ALSO
-------------------------------------------------------------------------------
Written with reference to formfilter.module which does a similar job through
access restrictions, whereas I want to trust my users, but avoid confusing
them. And clean up my own admin edit interface.
http://drupal.org/project/formfilter
This module is intended to be more lightweight than formfilter,
and does not have such an extensive admin UI.
Taxonomy terms selected on node forms are also set as context classes, so
it's possible to define rules that only apply when a certain term is
selected in the form.
vertical_tabs.module is excellent, and takes a different approach at minimizing
the screen size and hiding unwanted elements.
*This module has not been tested with and may not work well with vertical_tabs*
More instructions are on the config page, which can be found at
'admin/config/user-interface/advancedform'
To debug the css or see how it works, look at the path '/advancedform_css'
OTHERS:
nodeformsettings http://drupal.org/project/nodeformsettings
- a set of custom UI tweaks, half of which can now be done by this module.
compact forms http://drupal.org/project/compact_forms
- marginally tidies up some forms on the client side.
form defaults http://drupal.org/project/formdefaults
- advertises a UI for form_alter type operations. Untested
## BACKGROUND
BACKGROUND
-------------------------------------------------------------------------------
This is more useful for in-house development with a set of trusted content
editors. It was built for tutoring, where I needed to be able to demonstrate
the functionality of the site as editors would see it, yet still have access
......@@ -69,5 +46,4 @@ the time we start with ecommerce products etc.
Note this 'permission' isn't actually secure - the full form is still
available to browser hacks - like disable css or js
CSS-hide trick for context-sensitive forms developed by dman 2006
CSS-hide trick for context-sensitive forms developed by dman 2006.
name: 'Advanced Form'
type: module
description: 'D8 port of the Advanced form module'
description: 'Conditionally hide admin UI features.'
core_version_requirement: ^9.2.0 || ^10
package: 'Custom'
package: 'Other'
......@@ -14,11 +14,10 @@ use Drupal\node\NodeForm;
*/
function advancedform_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the advancedform module.
case 'help.page.advancedform':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('D8 port of the Advanced form module') . '</p>';
$output .= '<p>' . t('The Advancedform module allows conditionally hiding admin UI features.') . '</p>';
return $output;
}
return FALSE;
......
{
"name": "drupal/advancedform",
"type": "drupal-module",
"description": "D8 port of the Advanced form module",
"description": "Conditionally hide admin UI features.",
"keywords": ["Drupal"],
"license": "GPL-2.0+",
"homepage": "https://www.drupal.org/project/advancedform",
"minimum-stability": "dev",
"support": {
"issues": "https://www.drupal.org/project/issues/advancedform",
"source": "http://cgit.drupalcode.org/advancedform"
"source": "http://git.drupalcode.org/project/advancedform"
},
"require": { }
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Advancedform syntax examples</title>
</head>
<body>
---
label: 'Advancedform usage'
---
<h2>Examples</h2>
<p>
Internally, the hiding is done via CSS on the client-side, and CSS syntax and
selectors are used to identify the elements to remove.
<p>
You often want to hide the form elements "wrapper" div, so the containing
You often want to hide the form elements "wrapper" div, so the containing
element of items starting with #edit- will also be hidden.
<br/>
Eg, if you are trying to hide <code>'#edit-menu-description'</code>, then the whole
......@@ -49,15 +44,15 @@ are equivalent, both will work.
<p>
Normally the first token in your configs should match the specific form id.
<pre>&lt;form ... id="block-admin-configure" &gt;</pre>
Node forms are treated as a special case. You can target specific content types
Node forms are treated as a special case. You can target specific content types
with their explicit form id, eg:
<pre>&lt;form ... id="article-node-form" &gt;</pre>
A generic form rule for all node forms can also be defined using the pseudo-key
<code>node-form</code>,
This will be applied to edit forms for all types.
<pre>
node-form:#revision-information
page-node-form:#edit-date
......@@ -71,7 +66,7 @@ Hide date on all "Page" nodes, (CSS selector <code>#node-form.node-type-page</co
</li><li>
Hide URL alias and menu settings on all "Article" nodes.
</li><li>
Remove the "book outline" widget from "page" types
Remove the "book outline" widget from "page" types
<a href="#per-type">if the user is 'editor'</a>.<sup>*</sup>
</li></ul>
<small>True JSON would want all those values quoted, don\'t do that, the quotes will be added automatically for you</small>
......@@ -118,7 +113,7 @@ css-safe version of the role name.
<h3 id="per-taxonomy">Per-taxonomy rules</h3>
<p><em>Any</em> selectbox on the form will also insert an additional selector
into the form element you can use.
into the form element you can use.
The format is <code>selected-<b>tag</b></code>
<pre>
node-form:{.selected-marketing[#file-attachments]}
......@@ -140,7 +135,7 @@ page-node-form:{.user-role-<b>content-editor</b>.selected-<b>marketing</b>>:[#co
</code>
<p>
This will: <ul><li>
Hide comment settings on "page" nodes for all content editors when the
Hide comment settings on "page" nodes for all content editors when the
'marketing' option is selected from tags in the form.
</li></ul>
</p>
......
......@@ -34,7 +34,7 @@ class AdvancedFormSettingsForm extends ConfigFormBase {
$form['rules_global'] = [
'#type' => 'textarea',
'#title' => $this->t('Rules'),
'#description' => $this->t('Define the rules that will apply to all users.'),
'#description' => $this->t('Rule selectors to hide inputs, eg <code>node-form:[#revision-information]</code> will hide the revision information fieldset on node forms. One rule per line.'),
'#default_value' => $config->get('rules_global'),
];
return parent::buildForm($form, $form_state);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment