> */ public static function properties(): array { return self::core_properties() + Extensions::builder_config()['properties']; } /** * Core setting definitions, keyed by property. * * Control kinds: text, textarea, number, checkbox, select, name, lines, field. * * @return array> */ public static function core_properties(): array { return array( 'label' => array( 'label' => __( 'Label', 'flexsolutions-form-builder' ), 'control' => 'text', ), 'name' => array( 'label' => __( 'Field name', 'flexsolutions-form-builder' ), 'control' => 'name', 'help' => __( 'Used in mail as [name]. Letters, digits, - and _; must start with a letter.', 'flexsolutions-form-builder' ), ), 'required' => array( 'label' => __( 'Required', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'help' => array( 'label' => __( 'Help text', 'flexsolutions-form-builder' ), 'control' => 'text', 'help' => __( 'Shown under the field.', 'flexsolutions-form-builder' ), ), 'placeholder' => array( 'label' => __( 'Placeholder', 'flexsolutions-form-builder' ), 'control' => 'text', ), 'default_value' => array( 'label' => __( 'Default value', 'flexsolutions-form-builder' ), 'control' => 'text', ), 'default' => array( 'label' => __( 'Fill automatically from', 'flexsolutions-form-builder' ), 'control' => 'select', 'options' => array( '' => __( '(nothing)', 'flexsolutions-form-builder' ), 'get' => __( 'URL parameter with the same name', 'flexsolutions-form-builder' ), 'post_title' => __( 'Current page title', 'flexsolutions-form-builder' ), 'post_url' => __( 'Current page URL', 'flexsolutions-form-builder' ), 'post_id' => __( 'Current page ID', 'flexsolutions-form-builder' ), 'user_display_name' => __( 'Logged-in user\'s name', 'flexsolutions-form-builder' ), 'user_email' => __( 'Logged-in user\'s email', 'flexsolutions-form-builder' ), 'user_login' => __( 'Logged-in user\'s username', 'flexsolutions-form-builder' ), ), 'help' => __( 'Visitors can change these values.', 'flexsolutions-form-builder' ), ), 'minlength' => array( 'label' => __( 'Minimum length', 'flexsolutions-form-builder' ), 'control' => 'number', 'min' => 0, ), 'maxlength' => array( 'label' => __( 'Maximum length', 'flexsolutions-form-builder' ), 'control' => 'number', 'min' => 1, ), 'counter' => array( 'label' => __( 'Show a character counter', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'readonly' => array( 'label' => __( 'Read-only', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'autocomplete' => array( 'label' => __( 'Autocomplete', 'flexsolutions-form-builder' ), 'control' => 'select', 'options' => array( '' => __( '(none)', 'flexsolutions-form-builder' ), 'name' => 'name', 'given-name' => 'given-name', 'family-name' => 'family-name', 'email' => 'email', 'tel' => 'tel', 'organization' => 'organization', 'street-address' => 'street-address', 'postal-code' => 'postal-code', 'country-name' => 'country-name', 'url' => 'url', ), ), 'size' => array( 'label' => __( 'Width (characters)', 'flexsolutions-form-builder' ), 'control' => 'number', 'min' => 1, ), 'rows' => array( 'label' => __( 'Rows', 'flexsolutions-form-builder' ), 'control' => 'number', 'min' => 1, ), 'cols' => array( 'label' => __( 'Columns', 'flexsolutions-form-builder' ), 'control' => 'number', 'min' => 1, ), 'min' => array( 'label' => __( 'Minimum', 'flexsolutions-form-builder' ), 'control' => 'number', ), 'max' => array( 'label' => __( 'Maximum', 'flexsolutions-form-builder' ), 'control' => 'number', ), 'step' => array( 'label' => __( 'Step', 'flexsolutions-form-builder' ), 'control' => 'text', 'help' => __( 'e.g. 1, 0.5 or "any".', 'flexsolutions-form-builder' ), ), 'min_date' => array( 'label' => __( 'Earliest date', 'flexsolutions-form-builder' ), 'control' => 'date', ), 'max_date' => array( 'label' => __( 'Latest date', 'flexsolutions-form-builder' ), 'control' => 'date', ), 'choices' => array( 'label' => __( 'Choices (one per line)', 'flexsolutions-form-builder' ), 'control' => 'lines', 'help' => __( 'To route mail, write Label|email, e.g. Sales|sales@example.com, and put [field-name] in the To field. Visitors only see the label.', 'flexsolutions-form-builder' ), ), 'multiple' => array( 'label' => __( 'Allow multiple selections', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'include_blank' => array( 'label' => __( 'Add a blank first option', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'first_label' => array( 'label' => __( 'Placeholder option text', 'flexsolutions-form-builder' ), 'control' => 'text', 'help' => __( 'e.g. "Choose a team…". Shown first and cannot be submitted.', 'flexsolutions-form-builder' ), ), 'exclusive' => array( 'label' => __( 'Allow only one box to be ticked', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'free_text' => array( 'label' => __( 'Add a text box to the last choice (e.g. "Other")', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'first_last' => array( 'label' => __( 'Ask for first and last name separately', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'heading_text' => array( 'label' => __( 'Heading', 'flexsolutions-form-builder' ), 'control' => 'text', ), 'heading_level' => array( 'label' => __( 'Size', 'flexsolutions-form-builder' ), 'control' => 'select', 'options' => array( '2' => __( 'Large (h2)', 'flexsolutions-form-builder' ), '3' => __( 'Medium (h3)', 'flexsolutions-form-builder' ), '4' => __( 'Small (h4)', 'flexsolutions-form-builder' ), ), 'help' => __( 'Pick the level that fits the page: the page title is usually h1.', 'flexsolutions-form-builder' ), ), 'label_first' => array( 'label' => __( 'Put the text before the box', 'flexsolutions-form-builder' ), 'control' => 'checkbox', ), 'text' => array( 'label' => __( 'Text', 'flexsolutions-form-builder' ), 'control' => 'text', ), 'limit' => array( 'label' => __( 'Maximum file size', 'flexsolutions-form-builder' ), 'control' => 'text', 'help' => __( 'e.g. 500kb or 2mb. Default 1mb.', 'flexsolutions-form-builder' ), ), 'filetypes' => array( 'label' => __( 'Allowed file types', 'flexsolutions-form-builder' ), 'control' => 'text', 'help' => __( 'Separate with |, e.g. pdf|docx|jpg. Scripts and web pages are always refused.', 'flexsolutions-form-builder' ), ), 'questions' => array( 'label' => __( 'Questions (one per line, Question|answer)', 'flexsolutions-form-builder' ), 'control' => 'lines', 'help' => __( 'One question is picked at random. Add more accepted answers after extra |. Case and spacing are ignored.', 'flexsolutions-form-builder' ), ), 'html' => array( 'label' => __( 'HTML', 'flexsolutions-form-builder' ), 'control' => 'textarea', 'help' => __( 'Headings, paragraphs and other formatting. Scripts are removed when the form is saved.', 'flexsolutions-form-builder' ), ), 'cond_field' => array( 'label' => __( 'Show when field', 'flexsolutions-form-builder' ), 'control' => 'field', ), 'cond_op' => array( 'label' => __( 'Condition', 'flexsolutions-form-builder' ), 'control' => 'select', 'options' => array( 'is' => __( 'is', 'flexsolutions-form-builder' ), 'not' => __( 'is not', 'flexsolutions-form-builder' ), 'filled' => __( 'is filled in', 'flexsolutions-form-builder' ), 'empty' => __( 'is empty', 'flexsolutions-form-builder' ), ), ), 'cond_value' => array( 'label' => __( 'Value', 'flexsolutions-form-builder' ), 'control' => 'text', ), 'id' => array( 'label' => __( 'ID attribute', 'flexsolutions-form-builder' ), 'control' => 'text', 'advanced' => true, ), 'class' => array( 'label' => __( 'CSS classes', 'flexsolutions-form-builder' ), 'control' => 'text', 'advanced' => true, 'help' => __( 'Separate with spaces.', 'flexsolutions-form-builder' ), ), 'tabindex' => array( 'label' => __( 'Tab order', 'flexsolutions-form-builder' ), 'control' => 'number', 'advanced' => true, ), ); } /** * Field types: label, palette group, dashicon, and the properties shown. * * @return array> */ public static function types(): array { $text_like = array( 'label', 'name', 'required', 'placeholder', 'default_value', 'default', 'minlength', 'maxlength', 'counter', 'readonly', 'autocomplete', 'size', 'help', 'id', 'class', 'tabindex' ); $types = array( 'text' => array( 'label' => __( 'Text', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'editor-textcolor', 'props' => $text_like, ), 'email' => array( 'label' => __( 'Email', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'email', 'props' => $text_like, ), 'tel' => array( 'label' => __( 'Phone', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'phone', 'props' => $text_like, ), 'url' => array( 'label' => __( 'Website', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'admin-links', 'props' => $text_like, ), 'name' => array( 'label' => __( 'Name', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'admin-users', 'props' => array( 'label', 'name', 'required', 'first_last', 'placeholder', 'default', 'maxlength', 'readonly', 'help', 'id', 'class', 'tabindex' ), ), 'address' => array( 'label' => __( 'Address', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'location', 'props' => array( 'label', 'name', 'required', 'readonly', 'help', 'id', 'class', 'tabindex' ), 'help' => __( 'Street, city, region, postal code and country. When required, street, city and country must be filled in.', 'flexsolutions-form-builder' ), ), 'textarea' => array( 'label' => __( 'Paragraph', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'text', 'props' => array( 'label', 'name', 'required', 'placeholder', 'default_value', 'default', 'minlength', 'maxlength', 'counter', 'readonly', 'rows', 'cols', 'help', 'id', 'class', 'tabindex' ), ), 'number' => array( 'label' => __( 'Number', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'calculator', 'props' => array( 'label', 'name', 'required', 'placeholder', 'default_value', 'min', 'max', 'step', 'readonly', 'help', 'id', 'class', 'tabindex' ), ), 'date' => array( 'label' => __( 'Date', 'flexsolutions-form-builder' ), 'group' => 'basic', 'icon' => 'calendar-alt', 'props' => array( 'label', 'name', 'required', 'min_date', 'max_date', 'help', 'id', 'class', 'tabindex' ), ), 'select' => array( 'label' => __( 'Drop-down', 'flexsolutions-form-builder' ), 'group' => 'choice', 'icon' => 'menu-alt', 'props' => array( 'label', 'name', 'required', 'choices', 'first_label', 'include_blank', 'multiple', 'help', 'id', 'class', 'tabindex' ), ), 'radio' => array( 'label' => __( 'Radio buttons', 'flexsolutions-form-builder' ), 'group' => 'choice', 'icon' => 'marker', 'props' => array( 'label', 'name', 'required', 'choices', 'free_text', 'label_first', 'help', 'id', 'class', 'tabindex' ), ), 'checkbox' => array( 'label' => __( 'Checkboxes', 'flexsolutions-form-builder' ), 'group' => 'choice', 'icon' => 'yes-alt', 'props' => array( 'label', 'name', 'required', 'choices', 'exclusive', 'free_text', 'label_first', 'help', 'id', 'class', 'tabindex' ), ), 'acceptance' => array( 'label' => __( 'Consent', 'flexsolutions-form-builder' ), 'group' => 'choice', 'icon' => 'saved', 'props' => array( 'text', 'name', 'required', 'label_first', 'id', 'class', 'tabindex' ), ), 'range' => array( 'label' => __( 'Slider', 'flexsolutions-form-builder' ), 'group' => 'choice', 'icon' => 'leftright', 'props' => array( 'label', 'name', 'min', 'max', 'step', 'default_value', 'help', 'id', 'class', 'tabindex' ), ), 'file' => array( 'label' => __( 'File upload', 'flexsolutions-form-builder' ), 'group' => 'advanced', 'icon' => 'upload', 'props' => array( 'label', 'name', 'required', 'limit', 'filetypes', 'help', 'id', 'class', 'tabindex' ), ), 'hidden' => array( 'label' => __( 'Hidden value', 'flexsolutions-form-builder' ), 'group' => 'advanced', 'icon' => 'hidden', 'props' => array( 'name', 'default_value', 'default' ), ), 'quiz' => array( 'label' => __( 'Quiz', 'flexsolutions-form-builder' ), 'group' => 'advanced', 'icon' => 'editor-help', 'props' => array( 'label', 'name', 'questions', 'size', 'help', 'id', 'class', 'tabindex' ), ), 'group' => array( 'label' => __( 'Conditional group', 'flexsolutions-form-builder' ), 'group' => 'layout', 'icon' => 'randomize', 'props' => array( 'cond_field', 'cond_op', 'cond_value' ), 'help' => __( 'Fields inside are shown, required and sent only when the condition is met.', 'flexsolutions-form-builder' ), ), 'heading' => array( 'label' => __( 'Section heading', 'flexsolutions-form-builder' ), 'group' => 'layout', 'icon' => 'heading', 'props' => array( 'heading_text', 'heading_level' ), ), 'divider' => array( 'label' => __( 'Divider', 'flexsolutions-form-builder' ), 'group' => 'layout', 'icon' => 'minus', 'props' => array(), 'help' => __( 'A line that separates parts of the form.', 'flexsolutions-form-builder' ), ), 'html' => array( 'label' => __( 'Text / HTML', 'flexsolutions-form-builder' ), 'group' => 'layout', 'icon' => 'editor-code', 'props' => array( 'html' ), ), 'response' => array( 'label' => __( 'Message area', 'flexsolutions-form-builder' ), 'group' => 'layout', 'icon' => 'format-status', 'props' => array(), 'help' => __( 'Where the success or error message appears. Without it, the message is shown at the end of the form.', 'flexsolutions-form-builder' ), ), 'submit' => array( 'label' => __( 'Submit button', 'flexsolutions-form-builder' ), 'group' => 'layout', 'icon' => 'button', 'props' => array( 'text', 'id', 'class', 'tabindex' ), ), ); // Add-on types never replace a core type. $types += Extensions::builder_config()['types']; /** * Filters builder field types. Add-ons should prefer * tflexforms_register_field_type(), which also teaches the parser, * renderer and validator about the new tag. * * @param array> $types Types. */ return (array) apply_filters( 'tflexforms_builder_types', $types ); } /** * Palette groups. * * @return array */ public static function groups(): array { return array( 'basic' => __( 'Basic fields', 'flexsolutions-form-builder' ), 'choice' => __( 'Choices', 'flexsolutions-form-builder' ), 'advanced' => __( 'Advanced', 'flexsolutions-form-builder' ), 'layout' => __( 'Layout', 'flexsolutions-form-builder' ), ); } /** * Interface strings. * * @return array */ public static function strings(): array { return array( 'builder' => __( 'Visual builder', 'flexsolutions-form-builder' ), 'htmlMode' => __( 'Tags', 'flexsolutions-form-builder' ), 'addField' => __( 'Add a field', 'flexsolutions-form-builder' ), 'paletteHint' => __( 'Click a field to add it, or drag it into the form.', 'flexsolutions-form-builder' ), 'empty' => __( 'Your form is empty. Click or drag a field from the left to start.', 'flexsolutions-form-builder' ), 'dropInside' => __( 'Drop fields here', 'flexsolutions-form-builder' ), 'settings' => __( 'Field settings', 'flexsolutions-form-builder' ), 'noSelection' => __( 'Select a field to change its settings.', 'flexsolutions-form-builder' ), 'advanced' => __( 'Advanced', 'flexsolutions-form-builder' ), 'edit' => __( 'Edit', 'flexsolutions-form-builder' ), 'moveUp' => __( 'Move up', 'flexsolutions-form-builder' ), 'moveDown' => __( 'Move down', 'flexsolutions-form-builder' ), 'duplicate' => __( 'Duplicate', 'flexsolutions-form-builder' ), 'remove' => __( 'Delete', 'flexsolutions-form-builder' ), 'confirmRemove' => __( 'Delete this field?', 'flexsolutions-form-builder' ), 'confirmGroup' => __( 'Delete this group and the fields inside it?', 'flexsolutions-form-builder' ), 'done' => __( 'Done', 'flexsolutions-form-builder' ), 'required' => __( 'required', 'flexsolutions-form-builder' ), 'untitled' => __( 'Untitled', 'flexsolutions-form-builder' ), /* translators: %d: position in the form. */ 'moved' => __( 'Moved to position %d.', 'flexsolutions-form-builder' ), /* translators: %s: field type, e.g. Email. */ 'added' => __( '%s added.', 'flexsolutions-form-builder' ), 'removed' => __( 'Field deleted.', 'flexsolutions-form-builder' ), 'nameInvalid' => __( 'Use letters, digits, - and _, starting with a letter.', 'flexsolutions-form-builder' ), 'nameTaken' => __( 'Another field already uses this name.', 'flexsolutions-form-builder' ), /* translators: %s: previous field name. */ 'nameChanged' => __( 'Renaming a field changes its mail placeholder. Update the Mail tab if you used [%s].', 'flexsolutions-form-builder' ), 'customHtml' => __( 'Custom HTML', 'flexsolutions-form-builder' ), /* translators: %s: comma-separated field names. */ 'containsFields' => __( 'Contains: %s', 'flexsolutions-form-builder' ), /* translators: 1: field name, 2: condition (is, is not, …), 3: value. */ 'showWhen' => __( 'Show when %1$s %2$s %3$s', 'flexsolutions-form-builder' ), 'chooseField' => __( '— choose a field —', 'flexsolutions-form-builder' ), 'insert' => __( 'Insert', 'flexsolutions-form-builder' ), 'cancel' => __( 'Cancel', 'flexsolutions-form-builder' ), 'insertField' => __( 'Insert field', 'flexsolutions-form-builder' ), 'tagPreview' => __( 'Tag', 'flexsolutions-form-builder' ), 'defaultSubmit' => __( 'Send', 'flexsolutions-form-builder' ), 'defaultConsent' => __( 'I agree to the privacy policy', 'flexsolutions-form-builder' ), 'defaultChoices' => __( "Option 1\nOption 2\nOption 3", 'flexsolutions-form-builder' ), 'defaultQuestion' => __( 'What is 3 + 4?|7|seven', 'flexsolutions-form-builder' ), 'defaultHtml' => '

' . __( 'Section title', 'flexsolutions-form-builder' ) . '

', 'defaultHeading' => __( 'Section title', 'flexsolutions-form-builder' ), 'firstName' => __( 'First name', 'flexsolutions-form-builder' ), 'lastName' => __( 'Last name', 'flexsolutions-form-builder' ), 'street' => __( 'Street address', 'flexsolutions-form-builder' ), 'city' => __( 'City', 'flexsolutions-form-builder' ), 'postcode' => __( 'ZIP / Postal code', 'flexsolutions-form-builder' ), 'builderHelp' => __( 'Drag cards to reorder, or drop a card on the side of another to put them in one row. Fields inside a conditional group appear only when its condition is met.', 'flexsolutions-form-builder' ), 'joinRow' => __( 'Place beside the card before', 'flexsolutions-form-builder' ), 'leaveRow' => __( 'Move to its own row', 'flexsolutions-form-builder' ), 'columnWidth' => __( 'Column width', 'flexsolutions-form-builder' ), /* translators: 1: width of the column before the divider, e.g. 1/3, 2: width of the column after it. */ 'columnWidths' => __( 'Columns %1$s and %2$s', 'flexsolutions-form-builder' ), /* translators: %d: maximum number of columns in a row. */ 'rowFull' => __( 'A row holds up to %d columns.', 'flexsolutions-form-builder' ), /* translators: 1: column number, 2: number of columns in the row. */ 'joined' => __( 'Placed in column %1$d of %2$d.', 'flexsolutions-form-builder' ), 'leftRow' => __( 'Moved to its own row.', 'flexsolutions-form-builder' ), ); } /** * Everything the builder script needs. * * @return array */ public static function config(): array { return array( 'types' => self::types(), 'props' => self::properties(), 'tagTypes' => Tag_Parser::tag_types(), 'groups' => self::groups(), 'strings' => self::strings(), 'reserved' => 'tflexforms', 'maxNameLen' => 64, ); } }