hook_states() Reference

hook_states()

This is a list of properties available for the elements returned in implementations of hook_states. The keys of the the returned elements specify the machine readable state machine name.

Property Possible values Default value Description Required
#label * - A human readable label for the state machine Yes
#entity (node | user) - The entities on which the state of the machine will be tracked. Yes
#types An array of type names - Allows one to optionally restrict the state machine to work only with nodes of a certain type. Only available for the entity 'node'. No
#roles An array of role ids - Allows one to optionally restrict the state machine to work only with users with certain roles. Only available for the entity 'user'. No
#states '*' | Array of state names - A possible list of values of the state machine. If the string '*' is given, each string is interpreted as valid state. Yes
#init_state a valid state NULL This allows one to specify an initial default value for the state machine. It will be set, if the entity is being created, but no state is set for the machine. No.
#attribute_name String The machine name The state of a machine is tracked at $entity->states[#ATTRIBUTE_NAME]. So this can be used to customize this. E.g. so you can share one attribute name for different state machines, when you are sure that they work upon different entitites, e.g. different node types. No.
 
 

Drupal is a registered trademark of Dries Buytaert.