Making Attributes Editable - Mura Docs v7.0

Making Attributes Editable

When displaying an extended attribute in a layout template, you may want to make the attribute editable by content managers when they're using front-end editing features. This is accomplished by using  m.renderEditableAttribute.

Note: This feature only works on extended attributes with its Input Type set to TextBox or HTMLEditor.

Function Syntax

m.renderEditableAttribute(
  attribute
  , type
  , required
  , validation
  , message
, label
  , value
  , enableMuraTag
)

Parameters

Parameter Type Req/Opt Default Description
attribute string required   The attribute's name
type string opt text

Valid options are:

  • text
    • Treats the attribute as text being entered into a TextBox
  • HTMLEditor
    • When editing content via inline edit mode, and a content manager double clicks into the text, a HTML Editor toolbar will appear.
required boolean opt false If true, Mura will require a value to be entered before saving successfully.
validation regex opt blank Leave blank, or enter a JavaScript regular expression to use for validation purposes. Will trigger if a value is entered and a save is attempted.
message string opt empty string The message to display when the submitted value does not pass validation.
label string opt attribute name Text to display above the field when edited.
value string opt the attribute's stored value Optionally pass in a string to preset the value.
enableMuraTag boolean opt false If true, the value will be parsed by Mura's setDynamicContent to render any Mura [m] tags.

Example

The following example demonstrates how to use m.renderEditableAttribute for an attribute with its Input Type set to HTMLEditor.

<cfoutput>
  <div>
#m.renderEditableAttribute(
attribute='attributeName'
type='HTMLEditor'
label='Attribute Label'
)#
</div>
</cfoutput>