Forms settings

‹ back to Settings


MyPortal CMS allows you to create all kinds of web forms, which are then automatically constructed and controlled. You can create more forms categories and add forms into them. Any form can have an arbitrary number of fields, which are stored into the database. In the PHP script the whole form is available as a PHP array and it can be constructed with a simple foreach loop. The only HTML code you have to write, are the <form> and <input type="submit"> tags.

Add new forms category

When adding a new forms category you have to set some special settings to it: save to db, statistics, custom processing, allow submit, captcha and show default.

Forms category

  • Save to db saves form's data to database to be available anytime in the forms module.
  • Statistics enables forms statistics logging.
  • Custom processing defines a PHP file (must be in models folder), which is executed together with the form.
  • Allow submit can be set to none, once or once per session. That is the way to control how many times an user can submit a form.
  • Captcha is already created in a system folder and can be included in your form if needed.
  • Show default displays a form from default language if it is not translated into current language.

Create new form

You can add, delete or edit form fields very easily. This is an example of form with five different fields.

Forms category

Add a field to a form

When adding or editting a form field you can set:

  • label: a textual representation of a form field
  • name: attribute (for example <input type="..." name="name" value="..." />)
  • type: attribute (for example <input type="text" name="..." value="..." />)
  • value: attribute (for example <input type="..." name="..." value="1" />)
  • valid: options for form validation are req (required field), num (numeric), notnum (not numeric), nosp (no space), alp (letters only), alpnum (alphanumeric), date, email, money, checked, selected.
  • options: can be set in addition to other settings, for example "class":"blue","id":"form1", which results to <input type="..." name="..." value="..." class="blue" id="form1" />. For checkboxes and radio buttons you should also put there the data parameter with comma separated values, for example "data":"apple,pear,banana,lemmon", to create 4 checkboxes (or radios) with defined fruit values.

Forms add field

This is an example of adding a new text field to a form.

Custom processing

You can write your own script and do some little things after submitting a form. You can send data through email, save some data to database, create a few custom messages and so on. You have to write a PHP script and put it into template/models folder.

If you want to have additional checking in you custom processing script, you may want to stop the automatic forms behaviour (don't setcookie, don't insert into DB)... You just have to set the $error variable to true at the end of the script in order to do so.

‹ back to Settings

Try myPortal 2: