Add the "save and continue" button

Hi, I will briefly explain the problem.
I have a custom module and to speed up the entries, I would like to insert, at the top, next to the “Save” and “Cancel” buttons also the “Save and Continue” button, as it appears in other modules, many of the fields in this form are already filled and of course, when it goes to the next creation, the data must be filled as when it was first entered. In addition, I made a small change in suitecrm\custom\Extension\modules<MY_MODULE>\Ext\Layoutdefs_override_MODULE so that the creation takes place within the subpanel of another module:

array (
    0 => 
    array (
      // 'widget_class' => 'SubPanelTopButtonQuickCreate',
	  'widget_class' => 'SubPanelTopCreateButton',
    ),
    1 => 
    array (
      'widget_class' => 'SubPanelTopSelectButton',
      'mode' => 'MultiSelect',
    ),
  ),

this way, quickcreate is not executed inside the subpanel, but editview is executed directly.

How can I achieve this? Thank you.

I added these lines in:

suitecrm\custom\modules\<MY_MODULE>\metadata\editviewdefs.php

 'form' =>
      array(
		'buttons' =>
        array(
           'SAVE',
           'CANCEL',
           
          array(
            'customCode' => '{if $fields.status.value != "Completed"}<input title="{$APP.LBL_CLOSE_AND_CREATE_BUTTON_TITLE}" class="button" onclick="document.getElementById(\'status\').value=\'Completed\'; this.form.action.value=\'Save\'; this.form.return_module.value=\'<MY_MODULE>\'; this.form.isDuplicate.value=true; this.form.isSaveAndNew.value=true; this.form.return_action.value=\'EditView\'; this.form.return_id.value=\'{$fields.id.value}\'; if(check_form(\'EditView\'))SUGAR.ajaxUI.submitForm(this.form);" type="button" name="button" value="{$APP.LBL_CLOSE_AND_CREATE_BUTTON_LABEL}">{/if}',
          ),
        ),
	  ),

and the button I wanted appears, but only if I access from listview->create.
Instead, I would like it to appear when I click on the “create” button on the subpanel.
I think it depends on the fact that when accessing via subpanel’s create, it is redirected to

suitecrm/index.php

whereas if I click create from listview I am redirected to

suitecrm/index.php?action=ajaxui#ajaxUILoc=index.php&module=EditView...

@fab

There is a way to get started:

  1. Look at the files
    include/EditView/SubpanelQuickCreate.php
    include/EditView/EditView2.php
    include/EditView/SugarVCR.php
  2. Look at files in directory - themes/SuiteP/include/EditView
  3. Perhaps you should create custom file view.edit.php.

Yes, I had seen those files before, but I don’t know how to modify them for my needs.
Also in the subpanel I don’t use SubpanelQuickCreate.php but SubPanelTopCreateButton.php

@fab

The ‘Save and Continue’ button is in the object ‘SugarVCR’. Try adding an object when you open the editview form.

In SugarVCR I inserted

$GLOBALS[‘log’]->fatal(’***** EDIT VIEW test *****’);

and it is printed to the screen

I was able to add the “save and continue” button via subpanel, the problem is that if I press it, it takes me to the next record edit and not to the creation of a new record.
How do I solve this?

@fab

You have to create custom js and php code because the ‘Save and Continue’ button only works with existing records by default.

Okay, assuming I create the js and php code, how do I call it up? From where? Considering that I need to pass it some predetermined values that fill the form.

@fab

  1. Copy the file “themes/SuiteP/include/EditView/SugarVCR.tpl” to the user’s directory.
  2. Add your logic to the custom SugarVCR.tpl by including a condition to analyze what the next record should be (new or existing).
  3. Perhaps you should create custom file view.edit.php.