You are here

public function AccessControlKitHandlerInterface::objectFormAlter in Access Control Kit 7

Alters the add/edit form for an object to reflect ACK permissions.

It is up to the handler module to invoke this method as needed from hook_form_alter(). Implementations of this method should modify the object form so that the object may only be assigned to those realms in the access scheme where the user has "create" permission. The method should also prevent the object's assigned realms from being changed on edit.

For example, if the handler's objectRealms() method relates nodes to realms in the scheme by means of a certain list field's value, then when creating a new node, the user should only be allowed to select values in that list field that correspond to realms in which the user has "create" permission. And when editing an existing node, the list field should be disabled or hidden, so as to prevent non-admins from moving the node to a different realm in the access scheme. See the ack_node module for a complete example.

This method can also be used in combination with the objectFormValidate() and objectFormSubmit() methods to take additional actions when the object form is submitted. See the ACKMenuMap handler in the ack_menu module for an example of how this can be used to update data related to the object.

In addition to this method, the handler module is responsible for enforcing access to the delete button (if one exists) on the object's form. This is typically done by setting '#access' => FALSE on the button when the user does not have "delete" permission in any of the object's assigned realms.

Parameters

string $object_type: A string indicating the type of $object (e.g., node, menu_link).

mixed $object: The access-controllable object represented by this form.

array &$form: The form structure to alter. This can be a full form structure, or a sub-element of a larger form.

array &$form_state: An associative array containing the current state of the form.

string $form_id: String representing the name of the form itself. Typically this is the name of the function that generated the form.

array $realms: An array of the realm values that the user may choose for this object. Typically, this list corresponds to the user's "create" permissions for the object, and the parameter is omitted when editing an existing object. If omitted, form elements that correspond to realms in the scheme will be locked (either '#disabled' => TRUE or '#access' => FALSE).

See also

AccessControlKitHandlerInterface::objectFormValidate()

AccessControlKitHandlerInterface::objectFormSubmit()

1 method overrides AccessControlKitHandlerInterface::objectFormAlter()
AccessControlKitHandler::objectFormAlter in ./ack_handler.inc
Implements AccessControlKitHandlerInterface::objectFormAlter().

File

./ack_handler.inc, line 127
Contains the access control kit handler interface and base class.

Class

AccessControlKitHandlerInterface
Interface for an object access handler.

Code

public function objectFormAlter($object_type, $object, &$form, &$form_state, $form_id, $realms = NULL);