This macro generates a "front-end" form and permits content editing of a single piece of content from a page. This allows for *role based editing of existing content without the necessity of back end access. This macro does NOT, however, allow for the creation of new content. To create NEW content via a front-end form, webmasters should first create a "back-end form", utilize the submitContent macro to create a form, or create a custom submit content form.
*The "CMS Anonymous" role needs to have Edit permissions on the Content Type to allow "anonymous" front-end content editing.
Optionally, this macro can be used with captcha validation, create of a work flow task to a particular role moderator, and be set to automatically publish content, if desired. These and other settings are listed under "Options" in the "Macro Overview" section below.
Custom Field Handling
Custom fields are supported by the #submitContent and #submitContentEdit macros. Some javascript handling is required to display values in custom fields on the Front-end form. The sample code below can be placed in a custom code field named "source", which allows the front end content contributor to choose a host from a multi-select list that is dynamically created from existing hosts in the system:
##Multiselect for hosts where news and events will be pulled from
<select multiple size="10" id="msSource" name="msSource">
#set($siteList = $dotcontent.pull('+contentType:Host
+live:true +deleted:false',0,'Host.hostName'))
#foreach ($site in $siteList)
<option value="$!{site.identifier}"
#if($listTool.contains($source.split(',') ,
"$site.identifier"))selected="selected" #end
>$!{site.hostName}
</option>
#end
</select>
<script type="text/javascript">
function updateSource() {
var sourceHosts = '';
var hselect = document.getElementById("msSource");
for(var i = 0; i
< hselect.options.length; i++) {
if(hselect.options[i].selected) {
sourceHosts = sourceHosts + ',' + hselect.options[i].value;
}
}
document.getElementById("source").value = sourceHosts;
}
// Connect the onChange to the select
dojo.connect(dojo.byId("msSource"), "onchange", null, "updateSource");
</script>
Setting Default Field Values
The default value of a particular field can be set - $default<fieldVelocityName> - for any field (if applicable), before calling the submitContentEdit macro. ***Special Note***, the first letter of the velocity variable name needs to be capitalized regardless of how it appears on the Content Type. So if the variable name of the field is "answer" then the example below is how you would set a default value by capitalizing the first letter of the velocity variable name: