This hook allows a plugin to modify attributes and application behaviour when editing objects.

The StoreObject passed to the hook is read only. mutableCopy() should be used to make a copy, which is then modified. To work well with other plugins, start with an existing replacement object if one already exists.

You cannot modify the type of the object being created. The replacement object will be ignored if the first type isn’t exactly the same as the object passed in to the hook. This avoids confusing the user.

This hook may be called several times for each object creation and edit, both on display of the form and when the editor is submitted. Use the isTemplate and isNew arguments to determine which actions should be taken.

In general, only make changes when isTemplate is true. In this case, the application is about to display a template for a new object, which the user will complete and save. Be careful about using it in other circumstances. The user is unlikely to expect that the attributes will be changed when editing an existing object.

If you want to completely replace the user interface for creating a new type of object, for example, with some means to select fields, you can set redirectPath in the response to redirect the user’s browser. You should only redirect to paths which are handled by your plugin.


This hook implementation pre-fills the date field in new File objects with the current date:

P.hook('hPreObjectEdit', function(response, object, isTemplate, isNew) {
    if(isTemplate && object.isKindOf(T.File)) {
        var r = response.replacementObject || object.mutableCopy();
        r.append(new Date(), A.Date);
        response.replacementObject = r;


Name Type Description
object StoreObject The object being edited
isTemplate boolean Whether this object is a proposed template for a new object
isNew boolean Whether this object is a new object


Return information by changing these properties of the response object.

Name Type Description
replacementObject StoreObject An object to edit in place of the given object, or null for no effect
readOnlyAttributes Array An array containing a list attributes which are read only for this object
restrictionLiftedAttributes Array DEPRECATED (will be removed in later version, use hObjectAttributeRestrictionLabelsForUser instead): An array containing a list of attributes for which read-only and hidden attribute restrictions should not be applied for this object
redirectPath String If set, the user will be redirected to this path instead of editing the object

JavaScript template

P.hook('hPreObjectEdit', function(response, object, isTemplate, isNew) {
    // Respond to hook, for example
    // response.replacementObject = ...