# Presave

You can enter your own script when you press the "Save" button in EditView mode. To register a script use the method:

```PHP
SDK::setPreSave($module, $src);
```

*$module : the name of the module*  
*$src : the path of php file*

To remove the customization:

```PHP
SDK::unsetPreSave($module, $src = NULL);
```

*$module : the name of the module*  
*$src : the path of php file (if NULL, includes all scripts registered for that module)*

The following variables are available within the script:

*$type : the form name (“MassEditSave”, “DetailView”, “EditView”, “createTODO”, “QcEditView”, “ConvertLead”, “createQuickTODO”, “Kanban”)*  
*$values : (array) new values*  
  
For MassEditSave, you can know record that are going to be managed calling getListViewCheck($currentModule);

The following variables can be set:

*$status : (bool) whether or not the submit should be saved*  
*$message: (string) if not empty a popup with the message is shown*  
*$confirm: (bool) if true, a Javascript popup is shown asking for confirmation to continue, showing $message. In this case, $status must not be set.*  
*$focus : (string) in case of error, the element that takes the focus (only if $status = false)*  
*$changes: (array) values to assign to the fields (only if $status = false)*

The $focus and $changes variables are only available when $status is false and $type is one of 'EditView', 'createTodo', 'QcEditView', 'ConvertLead'.

<p class="callout info">**Hooks**  
include/js/general.js  
include/js/KanbanView.js  
modules/Calendar/script.js  
modules/Calendar/wdCalendar/sample.php  
modules/Leads/Leads.js  
modules/Users/Forms.php  
modules/VteCore/KanbanAjax.php  
Smarty/templates/Header.tpl  
Smarty/templates/ComposeEmail.tpl  
Smarty/templates/Popup.tpl</p>