Skip to content
Snippets Groups Projects
Commit ed1a5837 authored by jurgenhaas's avatar jurgenhaas
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
## ECA Recipe: Content validation
ID: eca_lib_0009
This example model changes the behaviour when editing a content of type "article" in a form:
- It groups the title and body field together
- It makes sure that the body field is not empty, when trying to publish the article.
### Installation
```shell
composer require drupal-eca-recipe/eca_lib_0009
cd web && php core/scripts/drupal recipe ../vendor/drupal-eca-recipe/eca_lib_0009
```
\ No newline at end of file
{
"name": "drupal-eca-recipe/eca_lib_0009",
"type": "drupal-recipe",
"description": "Content validation",
"license": "GPL-2.0-or-later",
"require": {
"drupal/eca_base": "*",
"drupal/eca_content": "*",
"drupal/eca_form": "*",
"drupal/text": "*"
}
}
langcode: en
status: true
dependencies:
config:
- field.field.node.article.body
- field.field.node.page.body
- field.storage.node.body
module:
- eca_base
- eca_content
- eca_form
id: eca_lib_0009
modeller: bpmn_io
label: 'Content validation'
version: v1
weight: null
events:
Event_07t9bjm:
plugin: 'form:form_process'
label: 'Processing article form'
configuration:
form_id: ''
entity_type_id: node
bundle: article
operation: 'default, edit'
successors:
-
id: Activity_0oquvx2
condition: ''
Event_0obipdz:
plugin: 'form:form_validate'
label: 'Validating article form'
configuration:
form_id: ''
entity_type_id: node
bundle: article
operation: 'default, edit'
successors:
-
id: Activity_0kuu2di
condition: ''
conditions:
Flow_1vzdsli:
plugin: eca_entity_field_value
configuration:
negate: false
case: false
expected_value: '1'
field_name: status
operator: equal
type: value
entity: node
Flow_1oy6uax:
plugin: eca_entity_field_value_empty
configuration:
negate: false
field_name: body
entity: node
gateways: { }
actions:
Activity_0oquvx2:
plugin: eca_form_add_group_element
label: 'Group title and body into "Authoring"'
configuration:
name: authoring
title: Authoring
open: true
weight: '0'
fields: 'title, body'
introduction_text: ''
summary_value: ''
successors: { }
Activity_0kuu2di:
plugin: eca_form_build_entity
label: 'Build node from submitted values'
configuration:
token_name: node
successors:
-
id: Activity_1wmvbc3
condition: Flow_1vzdsli
Activity_1wmvbc3:
plugin: eca_void_and_condition
label: 'Chain for AND condition'
configuration: { }
successors:
-
id: Activity_0qj9rwm
condition: Flow_1oy6uax
Activity_0qj9rwm:
plugin: eca_form_field_set_error
label: 'Set validation error on body field'
configuration:
message: 'The body must have a text when this article is supposed to be published.'
field_name: body
successors: { }
langcode: en
status: true
dependencies:
config:
- eca.eca.eca_lib_0009
id: eca_lib_0009
label: 'Content validation'
tags:
- forms
- 'field group'
- 'form field validation'
documentation: |-
This example model changes the behaviour when editing a content of type "article" in a form:
- It groups the title and body field together
- It makes sure that the body field is not empty, when trying to publish the article.
filename: ''
modeldata: |
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:qa="http://some-company/schema/bpmn/qa" id="sample-diagram" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="eca_lib_0009" name="Content validation" isExecutable="true" camunda:versionTag="v1">
<bpmn2:documentation>This example model changes the behaviour when editing a content of type "article" in a form:
- It groups the title and body field together
- It makes sure that the body field is not empty, when trying to publish the article.</bpmn2:documentation>
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="Changelog v1" value="Initial version" />
<camunda:property name="Tags" value="forms,field group,form field validation" />
</camunda:properties>
</bpmn2:extensionElements>
<bpmn2:startEvent id="Event_07t9bjm" name="Processing article form" camunda:modelerTemplate="org.drupal.event.form:form_process">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="form:form_process" />
</camunda:properties>
<camunda:field name="form_id">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="entity_type_id">
<camunda:string>node</camunda:string>
</camunda:field>
<camunda:field name="bundle">
<camunda:string>article</camunda:string>
</camunda:field>
<camunda:field name="operation">
<camunda:string>default, edit</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:outgoing>Flow_1c4lsz3</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Activity_0oquvx2" name="Group title and body into &#34;Authoring&#34;" camunda:modelerTemplate="org.drupal.action.eca_form_add_group_element">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_form_add_group_element" />
</camunda:properties>
<camunda:field name="name">
<camunda:string>authoring</camunda:string>
</camunda:field>
<camunda:field name="title">
<camunda:string>Authoring</camunda:string>
</camunda:field>
<camunda:field name="open">
<camunda:string>yes</camunda:string>
</camunda:field>
<camunda:field name="weight">
<camunda:string>0</camunda:string>
</camunda:field>
<camunda:field name="fields">
<camunda:string>title, body</camunda:string>
</camunda:field>
<camunda:field name="introduction_text">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="summary_value">
<camunda:string></camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1c4lsz3</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1c4lsz3" sourceRef="Event_07t9bjm" targetRef="Activity_0oquvx2" />
<bpmn2:startEvent id="Event_0obipdz" name="Validating article form" camunda:modelerTemplate="org.drupal.event.form:form_validate">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="form:form_validate" />
</camunda:properties>
<camunda:field name="form_id">
<camunda:string></camunda:string>
</camunda:field>
<camunda:field name="entity_type_id">
<camunda:string>node</camunda:string>
</camunda:field>
<camunda:field name="bundle">
<camunda:string>article</camunda:string>
</camunda:field>
<camunda:field name="operation">
<camunda:string>default, edit</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:outgoing>Flow_0dux81p</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:task id="Activity_0kuu2di" name="Build node from submitted values" camunda:modelerTemplate="org.drupal.action.eca_form_build_entity">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_form_build_entity" />
</camunda:properties>
<camunda:field name="token_name">
<camunda:string>node</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_0dux81p</bpmn2:incoming>
<bpmn2:outgoing>Flow_1vzdsli</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_0dux81p" sourceRef="Event_0obipdz" targetRef="Activity_0kuu2di" />
<bpmn2:task id="Activity_1wmvbc3" name="Chain for AND condition" camunda:modelerTemplate="org.drupal.action.eca_void_and_condition">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_void_and_condition" />
</camunda:properties>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1vzdsli</bpmn2:incoming>
<bpmn2:outgoing>Flow_1oy6uax</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1vzdsli" name="Set to be published?" camunda:modelerTemplate="org.drupal.condition.eca_entity_field_value" sourceRef="Activity_0kuu2di" targetRef="Activity_1wmvbc3">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_entity_field_value" />
</camunda:properties>
<camunda:field name="field_name">
<camunda:string>status</camunda:string>
</camunda:field>
<camunda:field name="operator">
<camunda:string>equal</camunda:string>
</camunda:field>
<camunda:field name="expected_value">
<camunda:string>1</camunda:string>
</camunda:field>
<camunda:field name="type">
<camunda:string>value</camunda:string>
</camunda:field>
<camunda:field name="case">
<camunda:string>no</camunda:string>
</camunda:field>
<camunda:field name="negate">
<camunda:string>no</camunda:string>
</camunda:field>
<camunda:field name="entity">
<camunda:string>node</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
<bpmn2:task id="Activity_0qj9rwm" name="Set validation error on body field" camunda:modelerTemplate="org.drupal.action.eca_form_field_set_error">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_form_field_set_error" />
</camunda:properties>
<camunda:field name="field_name">
<camunda:string>body</camunda:string>
</camunda:field>
<camunda:field name="message">
<camunda:string>The body must have a text when this article is supposed to be published.</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
<bpmn2:incoming>Flow_1oy6uax</bpmn2:incoming>
</bpmn2:task>
<bpmn2:sequenceFlow id="Flow_1oy6uax" name="Body is empty?" camunda:modelerTemplate="org.drupal.condition.eca_entity_field_value_empty" sourceRef="Activity_1wmvbc3" targetRef="Activity_0qj9rwm">
<bpmn2:extensionElements>
<camunda:properties>
<camunda:property name="pluginid" value="eca_entity_field_value_empty" />
</camunda:properties>
<camunda:field name="field_name">
<camunda:string>body</camunda:string>
</camunda:field>
<camunda:field name="negate">
<camunda:string>no</camunda:string>
</camunda:field>
<camunda:field name="entity">
<camunda:string>node</camunda:string>
</camunda:field>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
</bpmn2:process>
<bpmndi:BPMNDiagram id="sid-2c7133c8-80df-4bca-9cc3-c476ee2199b5">
<bpmndi:BPMNPlane id="sid-312ca64b-21d3-47e5-af2d-b16450bd2e25" bpmnElement="eca_lib_0009">
<bpmndi:BPMNShape id="Event_07t9bjm_di" bpmnElement="Event_07t9bjm">
<dc:Bounds x="222" y="132" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="197" y="175" width="87" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0oquvx2_di" bpmnElement="Activity_0oquvx2">
<dc:Bounds x="380" y="110" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0obipdz_di" bpmnElement="Event_0obipdz">
<dc:Bounds x="222" y="282" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="200" y="325" width="80" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0kuu2di_di" bpmnElement="Activity_0kuu2di">
<dc:Bounds x="380" y="260" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1wmvbc3_di" bpmnElement="Activity_1wmvbc3">
<dc:Bounds x="600" y="260" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0qj9rwm_di" bpmnElement="Activity_0qj9rwm">
<dc:Bounds x="820" y="260" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1c4lsz3_di" bpmnElement="Flow_1c4lsz3">
<di:waypoint x="258" y="150" />
<di:waypoint x="380" y="150" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0dux81p_di" bpmnElement="Flow_0dux81p">
<di:waypoint x="258" y="300" />
<di:waypoint x="380" y="300" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1vzdsli_di" bpmnElement="Flow_1vzdsli">
<di:waypoint x="480" y="300" />
<di:waypoint x="600" y="300" />
<bpmndi:BPMNLabel>
<dc:Bounds x="513" y="266" width="54" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1oy6uax_di" bpmnElement="Flow_1oy6uax">
<di:waypoint x="700" y="300" />
<di:waypoint x="820" y="300" />
<bpmndi:BPMNLabel>
<dc:Bounds x="722" y="282" width="76" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
langcode: en
status: true
dependencies:
config:
- field.storage.node.body
- node.type.article
module:
- text
id: node.article.body
field_name: body
entity_type: node
bundle: article
label: Body
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
display_summary: true
required_summary: false
allowed_formats: { }
field_type: text_with_summary
langcode: en
status: true
dependencies:
config:
- field.storage.node.body
- node.type.page
module:
- text
id: node.page.body
field_name: body
entity_type: node
bundle: page
label: Body
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
display_summary: true
required_summary: false
allowed_formats: { }
field_type: text_with_summary
langcode: en
status: true
dependencies: { }
name: Article
type: article
description: 'Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.'
help: null
new_revision: true
preview_mode: 1
display_submitted: true
langcode: en
status: true
dependencies: { }
name: 'Basic page'
type: page
description: "Use <em>basic pages</em> for your static content, such as an 'About us' page."
help: null
new_revision: true
preview_mode: 1
display_submitted: false
name: 'Content validation'
description: |-
This example model changes the behaviour when editing a content of type "article" in a form:
- It groups the title and body field together
- It makes sure that the body field is not empty, when trying to publish the article.
type: ECA
install:
- eca_base
- eca_content
- eca_form
- text
- node
config:
import:
node:
- field.storage.node.body
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment