# Function reference: Fields

## mm_renameField($field, $newlabel, $roles, $templates, $newhelp)

Renames one of the default fields or template variables within the manager.

$fields: The name of the fields this should apply to. Can only accept single field [Required]
$newlabel: The new text for the label [Required]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]
$newhelp: New text for the help icon with this field. The same restriction apply as when using mm_changeFieldHelp directly [Optional - default is leave unchanged]

`mm_renameField('longtitle', 'Page heading'); // Rename the longtitle field to "Page heading" for all users` `mm_renameField('longtitle', 'Case study name', '', '3'); // Rename the longtitle field to "Case study name" for documents using template ID "3"`

## mm_hideFields($fields, $roles, $templates)

Hides one or more of the default fields within the manager.

If a field to be hidden is a template variable, it must be prefixed by 'tv'.

$fields: The name(s) of the fields this should apply to. Can accept multiple fields separated by commas [Required]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

`mm_hideFields('link_attributes'); // Hide the link_attributes field for all users` `mm_hideFields('alias', '1', '3'); // Hide the alias field for users with role "1" editing documents using template ID "3"``mm_hideFields('tvmyVar', '2'); // Hide the template variable "myVar" for users with role "2"`

## mm_changeFieldHelp($field, $helptext, $roles, $templates)

Changes the help text that appears next to each field when the [?] icon is clicked.

Note that not all fields have help icons, notably "content" and "editor to use". In the future we might insert help icons for these missing ones.

$field: The name of the fields this should apply to. Can only accept single field [Required]
$helptext: The new help text that should appear when the help icon is clicked [Required]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

`mm_changeFieldHelp('pagetitle', 'This text will appear in the browser title bar and bookmarks'); // Change the help text for pagetitle for all users` `mm_changeFieldHelp('alias', 'How the URL will appear', '1'); // Change the help text for alias only for users with role "1"`

## mm_hideTemplates($tplIds, $roles, $templates)

Hides specified templates from the Templates drop down list

$tplIds: The IDs of the templates which should be hidden from the templates dropdown. Can accept multiple values separated by commas [Required]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

`mm_hideTemplates('0'); // Hide template 0 (blank) from all users` `mm_hideTemplates('0,4', '1'); // Hide templates 0 and 4 from users with role "1"`

## mm_inherit($fields, $roles, $templates)

Tells one or more fields to inherit their parent document's value (if it exists).

$fields: The name(s) of the fields this should apply to. Can accept multiple fields. [Required]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

`mm_inherit('pagetitle', '0,1'); // Inherit parent's pagetitle when users with role 0 or 1 are editing` `mm_inherit('pagetitle,longtitle'); // Inherit parent's pagetitle and longtitle for all users`

Note: this currently only works for text input fields

## mm_default($field, $value, $roles, $templates, $eval)

Provides a default value for specific fields in new documents / folders. Supports:

- pub_date - takes a PHP date object (Unix timestamp) to set the default publish date. If no value supplied, will be set to current date and time.
- unpub_date - takes a PHP date object (Unix timestamp) to set the default unpublish date. If no value set, will be set to current date and time.
- published - should "published" be checked? Takes boolean value. Note that if this conflicts with the pub/unpub dates, this may be overriden by Modx when the page is saved
- hide_menu - should "show in menu" be unchecked? Takes boolean value.
- show_in_menu - should "show in menu" be checked? Takes boolean value (opposite of hide_menu)
- searchable - should "searchable" be checked? Takes boolean value.
- cacheable - should "cacheable" be checked? Takes boolean value.
- clear_cache - should "empty cache" be checked? Takes boolean value.
- is_folder - should "container" be checked? Takes boolean value.
- is_richtext - should "rich text" be checked? If set to false, the page will automatically also set the "which_editor" field to none, and reload the page so this takes effect. Takes boolean value.
- log - should "log" be checked? Takes boolean value.
- content_type - default internet media (MIME) type, e.g. 'text/xml'

$field: The name(s) of the fields this should apply to. Currently accepts 'pub_date' or 'unpub_date' [Required]
$value: The default value for the field specified. If none is supplied the current date/time will be used. A static value can be supplied as a string, or PHP code (to calculate alternative dates) can be supplied if the eval parameter is set to true [Optional]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]
$eval: Should the value be evaluated as PHP code? Boolean [Optional - default is false]

`mm_default('pub_date'); // Always set the publish date on new documents to the current date and time` `mm_default('unpub_date', 'return date("d-m-Y H:i:s", now()+(60*60*24*28);', '', '4', true); // Automatically set the unpublish date to be four weeks in the future for documents with a template ID of "4"`

## mm_synch_fields($fields, $roles, $templates)

Synchronises the values of the specified fields at edit time - e.g. for making sure pagetitle and menutitle automatically read the same, particularly if one value is hidden. Works only with text inputs.

$fields: The name(s) of the fields that should be synched. Requires a minimum of 2 field names, comma separated [Required]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

`mm_synch_fields('pagetitle,menutitle,longtitle'); // Make the contents of these three fields always equal for all users and all documents`

## mm_requireFields($fields, $roles, $templates)

Makes fields required. Will append a red asterisk to a field to indicate it is required, and alert the user if they save the document without completing all the required fields.

This works on all fields EXCEPT

- keywords
- metatags
- hidemenu
- which_editor
- template
- menuindex
- show_in_menu
- parent
- is_folder
- is_richtext
- log
- searchable
- cacheable
- clear_cache
- content_type
- content_dispo
- which_editor

$fields: The name(s) of the fields that are required, comma separated [Required]
$roles: comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]
$templates: comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]

`mm_requireFields('pagetitle,pub_date'); // Make the page title and publication date fields required`