Creating And Editing User Documents

This is a user-contributed Extra. If you find issues or would like more info or help, please contact the author.
The following information was taken from an automated translation of the original Russian text - it may therefore not be 100% correct and meaningful.

The Content Controller allows web-users to create and edit records in MODxAPI tables. Extends the Form controller, which allows you to send mail after creating a record. When editing the records, sending mail is disabled, if necessary, it can be implemented using plug-ins to the save event (OnDocFormSave, etc.).

The form data is passed to the MODxAPI object as is, so the developer needs to take care of their correctness independently.

When editing records, you can prevent changes to individual fields using the keepDefaults parameter.

When you create a new record, the OnMakeDocUrl event is called, which passes the record id and the data array to the values of the record fields. This allows you to return a link to the created record, it will be available through the placeholder [+content.url+]. The link can be used in a letter with a notification about the creation of a new record.

You can also use the data of an authorized user, accessed through placeholders [+user.fullname+], [+user.email+], etc.

Parameters

Property Description
model

Class MODxAPI.

Possible values are the name of the MODxAPI class.

The default value is \ modResource.

modelPath

The path to the class file if the class does not load in advance.

Possible values are the relative path to the file.

The default value is assets / lib / MODxAPI / modResource.php.

userModel

Class for working with users.

Possible values are the class name.

The default value is \ modUsers

userModelPath

The path to the class file for working with users.

Possible values are the relative path to the file.

The default value is assets / lib / MODxAPI / modUsers.php

onlyUsers

Allow add entries only for registered users.

The possible values are 0, 1.

The default value is 1.

userGroups

Groups of users who are allowed to add or change records.

Possible values are the list of groups through a semicolon.

The default value is empty (any groups are allowed).

onlyOwners

Allows editing of records only by their authors. The author is determined by the field specified in the ownerField parameter.

The possible values are 0, 1.

The default value is 1.

ownerField

The name of the field that defines the owner of the record. If you work with modResource documents, this will be the name of the tv-parameter (in Evo, you do not create records by web users).

Possible values are the name of the field.

The default value is aid.

idField

The name of the key of the array $ _REQUEST, by which the id of the edited record is determined. If no key is specified, the controller is called in the record creation mode. Information about the controller mode can be obtained using the getMode method.

In the editing form, you need to provide a hidden field with the parameter name in which the record id will be stored.

The default value is id.

contentFields

Specifies the mapping of MODxAPI fields and form fields. You can not specify if the field names match. If the parameter is not specified, then the allowed fields and forbiddenFields parameters can limit the list of fields passed to the model.

Possible values are an array of the form:

&contentFields=`{
    "поле MODxAPI":"form field",
    "поле MODxAPI":"form field"
}

The default value is empty.

clearCache

Clear the cache after saving the record.

The possible values are 0, 1.

The default value is 0.

redirectTo

Redirects the user to the specified page after saving the new record. In the editing mode is not used.

Possible values are the id of the landing page or array.

The default value is empty.

editAfterCreate

Forward the user to the page to edit the created record. The page is specified in the parameter redirectTo.

The possible values are 1 or 0.

The default value is 0.

editTpl

Template form for editing a document.

Possible values are the name of the template specified by the rules for setting templates in DocLister.

The default value is the value of the formTpl parameter.

badOwnerTpl

A message template stating that the user is not the author of the document. Only edit mode.

Possible values are the name of the template specified by the rules for setting templates in DocLister.

The default value is a record from the Content lexicon with the [+edit.default_badOwnerTpl+] key.

badGroupTpl, badGroupEditTpl

A message template stating that the user is not in the group of users who are allowed to create and edit documents.

Possible values are the name of the template specified by the rules for setting templates in DocLister.

The default value is a record from the Content lexicon with a key [+create.default_badGroupTpl+] or [+edit.default_badGroupTpl+].

badRecordTpl

A message template stating that the user can not edit the entry: for example, the entry does not exist. Only edit mode.

Possible values are the name of the template specified by the rules for setting templates in DocLister.

The default value is an entry from the Content lexicon with the [+edit.default_badRecordTpl+] key.

exitTo

Redirects an unauthorized user to the specified page.

Possible values are the id of the landing page or array.

The default value is empty.

skipTpl, skipEditTpl

A message template for an unauthorized user. For editing mode - skipEditTpl.

Possible values are the name of the template specified by the rules for setting templates in DocLister.

The default value is an entry from the Content lexicon with the [+create.default_skipTpl+] key (edit.default_skipEditTpl).

successTpl

A template for a message about the successful saving of a new record.

Possible values are the name of the template specified by the rules for setting templates in DocLister.

The default value is a record from the Content lexicon with the key [+create.default_successTpl+]

editSuccessTpl

Template of the message about the successful update of the record.

Possible values are the name of the template specified by the rules for setting templates in DocLister.

The default value is empty.

Suggest an edit to this page.