BraDyCMS

BraDypUS CMS

View the Project on GitHub jbogdani/BraDyCMS

Build and embed forms in articles

BraDyCMS has a built-in (core) plugin to help you deal with web-form and collect data from your users easily. You can create all the web forms you need and embed them in article bodies. You can easily customize all fields and add file uploading buttons, just editing the main configuration file.

The plugin is located in:

Main menu > Plugins > User forms Or use [direct link](#userform/view).

Create a new custom form

To create a new custom form click the Add new user form button and enter a form id. Please remember, form ids must be unique. No spaces, dashes, hyphens or other special characters are allowed in the form id. Once the new form has been created you can customize it to meet your needs. See the Custom form syntax for details.


Embed a form in article’s body

Embedding a form in an article’s body is very simple. Just use the custom tag [[userform]] with the name/id of your form.

For example, to embed the form named contactus in an article’s body just add this simple tag:

[[userform]]contactus[[/userform]] You can aso provide a subject directly in the form definition, overwriting the custom one defined in the configuration file, e.g:

[[userform subject="Contact us"]]contactus[[/userform]]

BraDyCMS will do the rest for you: form formatting, validation and text and attachments delivery.


Custom form syntax

The configuration of a user form must follow a simple but rigid syntax. The configuration file must be a valid json file. BraDyCMS integrates a real-time validator to help finding any syntax error.

General data

Partial example

{
  "to": "info@bradypus.com",
  "from_email": "info@bradypus.com",
  "from_name": "BraDypUS communicating cultural heritage",
  "subject": "Contact form",
  "success_text": "Your message was successfully sent",
  "error_text": "Sorry, something went wrong and it was not possible to send your message"
  "inline": true,
  "to_user": "email",
  "confirm_text": "Dear %name%\nThank you for your message.\n\nYou are receiving this message because you filled a form on our site. If you did not, please report this abuse at info@bradypus.net.\n\nRegards\nBraDypUS team",
  ...
}

If smtp_host, smtp_username, smtp_password, smtp_port are defined the SMTP protocol will be used, otherwise the PHP’s mail function will be used.


Form element’s data

Form elements should be defined as an array. There is not a limit to the number of form elements that can be added to a form.

Each element should have a unique name and one of the predefined types.

If a field named subject is available and it is not empty, this value will overwrite default subject


Full example of a simple contact form

{
  "to": "info@bradypus.com",
  "from_email": "info@bradypus.com",
  "smtp_host": "smtp1.example.com;smtp2.example.com",
  "smtp_auth": true,
  "smtp_username": "info@bradypus.com",
  "smtp_password": "secret",
  "smtp_secure": "tls",
  "smtp_port": 587,

  "from_name": "BraDypUS communicating cultural heritage",
  "subject":"Contact form",
  "success_text":"Your message was successfully sent",
  "error_text": "Sorry, something went wrong and it was not possible to send your message"
  "inline": true,
  "to_user": "email",
  "confirm_text": "Dear %name%\nThank you for your message.\n\nYou are receiving this message because you filled a form on our site. If you did not, please report this abuse at info@bradypus.net.\n\nRegards\nBraDypUS team",
  "elements": [
    {
      "name": "name",
      "label": "Name",
      "placehoder": "Name",
      "type": "text",
      "is_required": "true"
    },
    {
      "name": "email",
      "label": "Email address",
      "placeholder": "Email address",
      "type": "text",
      "is_required": "true",
      "is_email": "true"
    },
    {
      "name": "phone_no",
      "label": "Phone number",
      "placeholder": "Phone number",
      "type": "text"
    },
    {
      "name": "location",
      "label": "Location",
      "type": "text"
    },
    {
      "name": "how_did_you_hear_about_us",
      "label": "How did you hear about us?",
      "placehoder": "How did you hear about us?",
      "type": "select",
      "options": [
        "google",
        "email message",
        "friends"
      ]
    },
    {
      "name": "comments",
      "label": "Comments",
      "placeholder": "Comments",
      "type": "longtext"
    },
    {
      "name": "uploadcv",
      "label": "Upload your CV",
      "type": "upload",
      "sizeLimit": "2097152",
      "allowedExtensions": [
        "pdf",
        "doc",
        "docx",
        "odt"
      ]
    }
  ]
}