Skip to content

Commit

Permalink
Merge pull request #3 from cosmocode/extensions-12-2019
Browse files Browse the repository at this point in the history
Extensions 12 2019
  • Loading branch information
Jmp00000001 authored Dec 20, 2019
2 parents 1caaa80 + 6b8879e commit c12a523
Show file tree
Hide file tree
Showing 44 changed files with 733 additions and 91 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ vendor
data/*
!data/EXAMPLE/config.yaml
!data/EXAMPLE/logo.png
!data/EXAMPLE/i_will_be_moved.txt

# logs
/logs

# local conf
/conf/*.local.yaml

# export directory
/export
10 changes: 10 additions & 0 deletions app/dependencies.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);

use CosmoCode\Formserver\Service\FileExporter;
use CosmoCode\Formserver\Service\Mailer;
use DI\ContainerBuilder;
use Psr\Container\ContainerInterface;
Expand All @@ -14,4 +15,13 @@
return new Mailer($mailSettings);
}
]);

$containerBuilder->addDefinitions([
FileExporter::class => function (ContainerInterface $c) {
$settings = $c->get('settings');
$mailSettings = $settings['fileExporter'] ?? [];

return new FileExporter($mailSettings);
}
]);
};
1 change: 1 addition & 0 deletions conf/language-de.default.yaml → conf/language.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ button_send : Senden
button_upload: Datei hochladen
button_upload_replace: Datei ersetzen
uploaded_file: Hochgeladene Dateien
upload_info: Die ausgewählte Datei wird beim Speichern oder Senden hochgeladen und geprüft
1 change: 1 addition & 0 deletions conf/language.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ button_send : Send
button_upload: Upload file
button_upload_replace: Replace uploaded file
uploaded_file: Saved file
upload_info: The selected file will be uploaded and checked after saving or sending the form
2 changes: 2 additions & 0 deletions conf/settings.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ settings:
encryption: ~
username: ~
password: ~
fileExporter:
dir: export
14 changes: 12 additions & 2 deletions data/EXAMPLE/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ meta:
- [email protected]
cc:
- fieldset0.fieldset_dynamic.email1
export: i_will_be_moved.txt
saveButton: true
tooltip_style: 'border: 1px solid cyan'
language: de
form:
fieldset0:
type: fieldset
Expand All @@ -25,6 +29,11 @@ form:
- 'Static elements'
- 'Dynamic elements'
- 'Fieldset columns'
hr0:
type: hr
column: is-full
color: '#f5f5f5'
height: 2
fieldset_static:
type: fieldset
label: 'Static form elements'
Expand Down Expand Up @@ -62,6 +71,7 @@ form:
validation:
match: /[a-zA-Z0-9]/
required: false
tooltip: 'Optional input\nAllowed characters: a-Z, 0-9'
numberinput1:
type: numberinput
label: Numberinput
Expand Down Expand Up @@ -92,7 +102,7 @@ form:
dropdown1:
type: dropdown
label: 'Dropdown'
default: 'Please choose'
empty_label: 'Please choose'
choices:
- 'Choice #1'
- 'Choice #2'
Expand All @@ -103,7 +113,7 @@ form:
label: 'Checklist'
choices:
- 'Choice #1'
- 'Choice #2'
- 'Choice #2 [a nice link](https://www.cosmocode.de)'
- 'Choice #3'
upload1:
type: upload
Expand Down
1 change: 1 addition & 0 deletions data/EXAMPLE/i_will_be_moved.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
With the default configuration i will be moved to 'export/'
2 changes: 1 addition & 1 deletion doc/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

All settings and message strings are defined in `conf/`

You can override them by copying `*.default.yaml` to `*.local.yaml` and adjusting the values.
You can override the defaults by copying `settings.default.yaml` and/or `language.default.yaml` to `*.local.yaml` and adjusting the values. Also see [Language Settings](meta.md#Translations)

50 changes: 44 additions & 6 deletions doc/formelements.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Fieldsets group other form elements (including nested fieldsets).
Options:
* `children` _(required)_ - containing child form elements
* `tablestyle` _(optional)_ set table view true or false. This will color the rows like zebrastripes. Labels of the containing formElements are hidden. The tablehead row will be populated from the labels from the children of the first fieldset. If cells in the first row must be skipped then [Spacers](#spacers) can be used.
* `toggle` _(optional)_ - the fieldset is disabled and hidden until the toggle condition is met
* `field` - dotted path to the field whose value will be evaluated to match the toggle condition
* `value` - required value to toggle the fieldset on
Expand Down Expand Up @@ -107,17 +108,51 @@ Options:
type: hidden
value: "hidden value"
```


### Spacer

Representation of a empty table cell. Should be used in table fieldset (tableStyle: true).
Options:
* `label` _(required)_ - The label. If the spacer is inside the first fieldset of a table fieldset (tableStyle: true) then the label will be used
* `double` _(optional)_ - If set to true also skips cell below

```yaml
<id>:
type: spacer
label: "label"
double: true
```

### Horizontal line
Representation of a hr.

Options:
* `column` _(optional)_
* `color` _(optional)_ - The color of the hr
* `height` _(optional)_ - The height of the hr

```yaml
<id>:
type: hr
column: is-full
color: '#f5f5f5'
height: 2
```

## Dynamic fields (user input)

All dynamic fields have a value the user can enter.
They are required by default.

Options:
* `validation` _(optional)_ - used to apply [validation](validation.md)
* `tooltip` _(optional)_ - Shows a hint for the form element. Also see [Tooltip styling](meta.md#Tooltips)

```yaml
<id>:
type: <type>
tooltip: 'A useful hint for this field.'
validation:
required: false
match: /^regex_expression$/
Expand Down Expand Up @@ -243,20 +278,22 @@ Options:
Representation of a select input.

Options:
* `choices` _(required)_ - defines available options
* `default` _(optional)_ - a placeholder text shown if no value was chosen (e.g. "Please select"). **Note:** this is not a real option and has no value that could be saved.
* `choices` _(required)_ - defines available options. Markdown ist supported.
* `empty_label` _(optional)_ - a placeholder text shown if no value was chosen (e.g. "Please select"). **Note:** this is not a real option and has no value that could be saved.
* `multiselect` _(optional)_ - enables selecting multiple options
* `size` _(optional)_ - if multiselect is turned on this defines the number of rows shown
* `default` _(optional)_ : Preselects a choice. This is just triggered if the form was never saved before. **Preselect in toggles are not supported yet.** **BREAKING CHANGE until version 1.0.4 this parameter was used for empty_label**

```yaml
<id>:
type: dropdown
label: dropdown label
multiselect: true
size: 3
default: choose an option
empty_label: choose an option
default: 'first choice [a nice link](https://www.cosmocode.de)'
choices:
- first choice
- first choice [a nice link](https://www.cosmocode.de)
- second choice
```

Expand All @@ -266,15 +303,16 @@ Representation of a checkbox group.

Options:
* `alignment` _(optional)_ - sets the alignment of the checkboxes, possible values are `vertical` or `horizontal` (default)
* `choices` _(required)_ - defines available options/checkboxes

* `choices` _(required)_ - defines available options/checkboxes. Markdown is supported.
* `default` _(optional)_ : Preselects a choice. This is just triggered if the form was never saved before. **Preselect in toggles are not supported yet.**
```yaml
<id>:
type: checklist
label: checklist label
alignment: vertical
validation:
required: false
default: 'First choice'
choices:
- First choice
- Second choice
Expand Down
50 changes: 50 additions & 0 deletions doc/meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,53 @@ Your CSS file will be included after our basic styles, which are mostly plain [B
```
An email with user input and attached uploads will be sent to configured addresses. A copy can be sent to an address from an email field if you provide the fieldId(s) in the `cc` section.

## Translations

```yaml
language: de
```

The set language will be loaded from ./conf/language-{{language}}.yaml.

At first ./conf/language.default.yaml gets loaded.

If ./conf/language.local.yaml exists it will override all set strings from the default file.

Finally ./conf/language-{{language}}.yaml. overrides all set strings from the previous files


## File export options

```yaml
export: file_to_be_moved.txt
```

When the form email gets send the given file (in this case file_to_be_moved.txt) will be moved to the export directory. The export directory is set by default to ./export. It can be changed by overriding the default settings (./conf/settings.default.yaml):
Create / Edit the file ./conf/settings.local.yaml.
Add:
```yaml
fileExporter:
dir : <anotherFolder>
```

The directory is always relative from the projects root dir.

## Visibility Savebutton

```yaml
saveButton: true
```

The visibilty of the save button can be toggled.
If this option is not set the button will be shown by default.

## Tooltips

```yaml
tooltip_style: 'border: 1px solid cyan'
```

This setting controls the tooltip button style attribute.

Every tooltip for this form is affected.
Loading

0 comments on commit c12a523

Please sign in to comment.