CommonDBTM::initForm PHP Method

initForm() public method

Initialize item and check right before managing the edit form
public initForm ( $ID, array $options = [] ) : value
$ID Integer ID of the item/template
$options array Array of possible options: - withtemplate : 1 for newtemplate, 2 for newobject from template
return value of withtemplate option (exit of no right)
    function initForm($ID, array $options = array())
    {
        if (isset($options['withtemplate']) && $options['withtemplate'] == 2 && !$this->isNewID($ID)) {
            // Create item from template
            // Check read right on the template
            $this->check($ID, READ);
            // Restore saved input or template data
            $input = $this->restoreInput($this->fields);
            // If entity assign force current entity to manage recursive templates
            if ($this->isEntityAssign()) {
                $input['entities_id'] = $_SESSION['glpiactive_entity'];
            }
            // Check create right
            $this->check(-1, CREATE, $input);
        } else {
            if ($this->isNewID($ID)) {
                // Restore saved input if available
                $input = $this->restoreInput($options);
                // Create item
                $this->check(-1, CREATE, $input);
            } else {
                // Existing item
                $this->check($ID, READ);
            }
        }
        return isset($options['withtemplate']) ? $options['withtemplate'] : '';
    }
CommonDBTM