Forms Overview
Total CMS provides a comprehensive form building system accessible through the cms.form object in Twig templates. All form methods are available through the TotalFormFactory class.
Accessing Form Methods
Section titled “Accessing Form Methods”All form functionality in Total CMS is accessed through the cms.form object:
{# Access form methods through cms.form #}{{ cms.form.blog() }}{{ cms.form.text('my-text-id') }}{{ cms.form.builder('mycollection').build() }}Note: The old method of importing form macros ({% import "totalform.twig" as form %}) is deprecated. Always use cms.form for accessing form functionality.
Default Field Arguments
Section titled “Default Field Arguments”field = type of the field data from Total CMS: text, number, date, etctype = type of the inputclass = classes added to the fieldvalue = value of the fieldlabel = label of the fielddefault = default value of the field if object is not set or value is empty (date fields support natural language)placeholder = placeholder of the fieldhelp = help text of the fieldicon = show iconrequired = required fielddisabled = disable fieldreadonly = readonlymin = minimum valuemax = maximum valuestep = step valuepattern = pattern for validationautogen = template string to autogenerate a value (in ID)settings = settings array added to form-field data-settings attributeminlength = minimum length of the field{# Example of using field settings #}{{ cms.form.text('my-text-id', {}, { class : "custom-class", value : "Set Value", label : "Text Label", default : "Default Value", placeholder : "Placeholder", help : "Help Text", icon : true, required : true, readonly : true, disabled : true, pattern : "\S+", minlength : "10",}) }}Premade Collection Forms
Section titled “Premade Collection Forms”Total CMS provides ready-to-use forms for standard collection types:
{# Blog form with all fields #}{{ cms.form.blog() }}
{# Single field forms #}{{ cms.form.checkbox(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.color(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.date(id, formSettings = {}, fieldSettings = {}) }} {# Supports natural language defaults #}{{ cms.form.datetime(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.email(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.image(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.number(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.range(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.select(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.styledtext(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.svg(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.text(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.textarea(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.toggle(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.url(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.file(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.depot(id, formSettings = {}, fieldSettings = {}) }}{{ cms.form.gallery(id, formSettings = {}, fieldSettings = {}) }}
{# Feed form #}{{ cms.form.feed() }}