Status 0.0.9 alpha (experimental)
MDForm is an extension for Datenstrom Yellow that allows you to create HTML forms using simple Markdown-formatted files.
It provides a secure way to collect data, supporting multiple input types and dispatch methods such as email notifications and CSV logging.
Learn more about Yellow CMS extensions.
This extension parses specific Markdown syntax within .mdf or .md files to generate functional web forms.
The extension includes built-in security features like CSRF protection and rate limiting to prevent spam and abuse.
- Datenstrom Yellow CMS
- PHP 7.4 or higher
- Write permissions to system/workers/ folder
- Download the extension files.
- Copy
mdform.phpto yoursystem/extensionsdirectory. - Copy
mdform.cssto yourmedia/assetsdirectory. - Create a folder named
media/forms/to store your form definitions.
your-site/
├── system/
│ └── workers/
│ └── mdform.php ← Place the file here
├── media/
│ ├── forms/ ← Create this folder for form definitions
│ └── tables/ ← CSV output will be stored here
└── index.php
It is recommended to change MDFormHashPasskey in the configuration to an individual salt random string to secure your forms against CSRF attacks.
You can customize the extension behavior in your system/config/config.ini file using the following settings:
| Setting | Default Value | Description |
|---|---|---|
MDFormDirectory |
media/forms/ |
Where form definition files are stored. |
MDFormDirectoryCSVOutput |
media/tables/ |
Where CSV data is saved. |
MDFormEmail |
noreply@server.com |
Default sender email address. |
Create a file (e.g., contact.mdf) in media/forms/. Use the following syntax:
### A Simple Contact Form
Full Name: [Your First and Last Name]{name}*
Email: [your@email.com]{email}*
Birthday: [DD/MM/YYYY;1900-01-01..TODAY]
Message: [Your message to us.....]
Newsletter: [Subscribe to newsletter: OFF/ON]*denotes a mandatory field.{email}defines the HTML5 autocomplete attribute.[ON/OFF]creates a preselected toggle switch. Use[OFF/ON]to make it prechecked.
Add the form to any Yellow page using the [mdform] shortcut:
[mdform filename dispatch]
Example:
[mdform contact.mdf email,csv,html] or [mdform contact.mdf "email csv html"]
This will display the form from contact.mdf, send an email, save the result to a CSV, and show a confirmation on the page.
Just remove the options you not would like to use.
You can style the form by editing media/assets/mdform.css. The extension wraps all elements in a .mdform-container class and uses .mdform-group for individual fields for easy targeting.
Update the text in system/settings/system.ini: if you want to change it for all your forms.
For page specific email text add a YAML to the page header:
MDFormMailHeader: Page Custom Header
MDFormMailFooter: Page Custom Footer
You can use field valiables to use text elements:
Example:
MDFormMailHeader: Thanks for you email @sendershort \n this mail was sent from @sender
MDFormMailFooter: @title :: @sitename \n Please reply to: @usermail @author
This variables are avilable:
**Header:**
@sendershort -> Output: $name - Example Result: John Doe
@sender -> Output: $name <$email> - Example Result: John Doe <john.doe@mail.com>
Note this variable only avilabe if the form (.mdf file) contins related fields with the {autofill} option:
Your Name: [Your First and Last Name]{name}
Your Email: [your@email.com]{email}
**Footer:**
@sitename -> Sitename as defined in `yellow-system.ini`
@sitemail -> Email address from the setting in `yellow-system.ini` (standard setting is just "noreply")
@usermail -> Email address auf the author
@author -> Author of the page
@title -> Title of the page
Adding as third parameter captcha to the [mdform] shortcut.
Example:
[mdform contact.mdf html,email captcha]
In the page YAML header add this:
MDFormAutocomplete: OFF] or MDFormAutocomplete: ON`
Note: most modern browsers seems not to repect this setting
For bug reports or feature requests, please visit the GitHub repository.
GNU GENERAL PUBLIC LICENSE - Feel free to use, modify, and distribute. Markdown Form Extension for Datenstrom Yellow CMS
Special thanks to:
- Giovanni Salmeri for the extension: Yellow Table
- Anna Svensson for the extension: Yellow Contact
Your extensions have been the main inspiration and learning resource for this extension. Thank you for sharing your knowledge with the Yellow CMS community!
Use in production at your own risk. Back up your data regularly and test thoroughly before deploying to production environments.
Made with 💛 for the Yellow CMS Community
