Hi,
I canât find how to add controls on the fields in the Quick Creation panel in the submenus.
For example for the custom module âBull_pezziâ i already inserted the controls in the file /custom/modules/Bull_pezzi/views/view.edit.php
and modified the file /custom/modules/Bull_pezzi/metadata/editviewdefs.php
to override the functionality of the âSaveâ button:
form' =>
array (
buttons' =>
array (
0 =>
array (
customCode' => '<input title="Save [Alt+S]" accesskey="S" class="button primary" onclick="var _form = document.getElementById(\'EditView\'); _form.action. value=\'Save\'; if(customJavascriptValidation(EditView\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="Save" id="SAVE">',
),
These controls do not work in the related quick creation panel (for the subpanel Bull_pezzi).
Do I need to run the file /custom/modules/Bull_pieces/metadata/quickcreatedefs.php
?
Thanks
Hi, @web_elinet
All buttons locked in file: include/EditView/SubpanelQuickCreate.php
Look at line of the file:
...
$this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
...
Hi, I wonder if it is possible to override the file include/EditView/SubpanelQuickCreate.php
and which path to use for the specific module?
To change the functionality of the âSaveâ button just customize the line $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
?
Thanks
@web_elinet
You can do it
- for all modules in file:
âcustom/include/MVC/View/views/view.edit.phpâ
- for one module in file:
âmodules/<module_name>/views/view.edit.phpâ
- or make special tpl for one module:
âmodules/<module_name>/tpls/QuickCreate.tplâ
If you will use the third variant you should switch on the variable âuseForSubpanelâ in file âmodules/<module_name>/views/view.edit.phpâ. For example look at âmodules/Accounts/views/view.edit.phpâ
Unfortunately as written in the initial topic I have already customized the file /modules/Bull_pieces/views/view.edit.php
but these changes canât be seen in the Quick Create panel in the submenus.
Let me clarify a little bit, I have 2 modules âBull_Elencoâ and âBull_piecesâ, related as one to many, so in the module âBull_listâ I have a subpanel showing âBull_listâ.
I should just be able to overwrite the functionality of the âSaveâ button of the quick creation panel, so that I can make the same checks on the fields I entered in the âEdit Viewâ of the same module before submitting.
@web_elinet
For you function in file view.edit.php:
public function display()
{
if ($this->ev->view === 'QuickCreate') {
$this->ev->defs['templateMeta']['form']['buttons'] = array(
0 =>
array (
'customCode' => '<input title="Save [Alt+S]" accesskey="S" class="button primary" onclick="var _form = document.getElementById(\'EditView\'); _form.action. value=\'Save\'; if(customJavascriptValidation(EditView\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="Save" id="SAVE">',
),
'SUBPANELCANCEL',
'SUBPANELFULLFORM');
}
parent::display();
}
Hello p.konetskiy,
I inserted the code in the file eview.edit.php but I have the impression that when I open the QuickCreate panel, the logical condition
if ($this->ev->view === 'QuickCreate')
is not valid, to test it I inserted some debug lines after the logic condition
var_dump($this->ev->view);
die();
These are not processed
Instead correctly, in the edit view of the form is printed the value of
$this->ev->view
(string(8) âEditViewâ)
I attach my file /custom/modules/Bull_pezzi/views/view.edit.php and /custom/modules/Bull_pezzi/metadata/editviewdefs.php file.zip (1.6 KB)
Thanks
Hello, @web_elinet!
I think that you didnât be attentive very much.
- You miss variable âuseForSubpanelâ and the function â__constructâ.
- The line âparent::display();â should be after âifâ.
- If you call command âdie;â the script stop execute.
This is code of file âcustom/modules/Bull_pezzi/views/view.edit.phpâ special for you:
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
class CustomBull_pezziViewEdit extends ViewEdit
{
public function __construct()
{
parent::__construct();
$this->useForSubpanel = true;
$this->useModuleQuickCreateTemplate = true;
}
function preDisplay()
{
parent::preDisplay();
$js="
<script type=\"text/javascript\">
function customJavascriptValidation(thisView){
var returnValue;
var value1=document.getElementById('name').value;
if(value1!=''){
return check_form('EditView');
}
else{
alert('Inserire un valore non vuoto');
return false;
}
}
</script>";
echo $js;
}
public function display()
{
if ($this->ev->view === 'QuickCreate') {
$GLOBALS['log']->fatal(get_class()." ". __FUNCTION__." this->ev:\n ".print_r($this->ev,true));
$this->ev->defs['templateMeta']['form']['buttons'] = array(
0 =>
array (
'customCode' => '<input title="Save [Alt+S]" accesskey="S" class="button primary" onclick="var _form = document.getElementById(\'EditView\'); _form.action. value=\'Save\'; if(customJavascriptValidation(EditView\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="Save [Alt+S]" id="SAVE">',
),
'SUBPANELCANCEL',
'SUBPANELFULLFORM');
}
parent::display();
}
}
Hello p.konetskiy,
thanks for the help, now it works.
I had not set the two fields to true:
$this->useForSubpanel = true;
$this->useModuleQuickCreateTemplate = true;
Sorry, I didnât mean to waste your time, unfortunately I didnât dwell on your suggestion because I didnât use the third variant
:
If you will use the third variant you should switch on the variable âuseForSubpanelâ in file âmodules/<module_name>/views/view.edit.phpâ. For example look at âmodules/Accounts/views/view.edit.phpââ.
If it can be useful to report the view.edit.php code, this is a test, the JsValidationQuickCreate() function can be implemented with the desired controls.
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
class CustomBull_pezziViewEdit extends ViewEdit
{
public function __construct()
{
parent::__construct();
$this->useForSubpanel = true;
$this->useModuleQuickCreateTemplate = true;
}
function preDisplay()
{
parent::preDisplay();
$js="
<script type=\"text/javascript\">
function customJavascriptValidation(thisView){
var returnValue;
var value1=document.getElementById('name').value;
if(value1!=''){
return check_form('EditView');
}
else{
alert('Inserire un valore non vuoto');
return false;
}
}
</script>";
echo $js;
}
public function display()
{
if ($this->ev->view === 'QuickCreate') {
$jsq="
<script type=\"text/javascript\">
function JsValidationQuickCreate(elem_id){
console.log($('#'+elem_id+' #name').val());
var returnValue;
var value1=$('#'+elem_id+' #name').val();
if(value1!=''){
return true;
}
else{
alert('Inserire un valore non vuoto');
return false;
}
}
</script>";
echo $jsq;
//$GLOBALS['log']->fatal(get_class()." ". __FUNCTION__." this->ev:\n ".print_r($this->ev,true));
$this->ev->defs['templateMeta']['form']['buttons'] = array(
0 =>
array (
'customCode' => '<input title="Save" class="button" onclick="var _form = document.getElementById(\'form_SubpanelQuickCreate_Bull_pezzi\'); disableOnUnloadEditView(); _form.action.value=\'Save\'; if(JsValidationQuickCreate(\'form_SubpanelQuickCreate_Bull_pezzi\')) return SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="Save" id="SAVE">',
),
'SUBPANELCANCEL',
'SUBPANELFULLFORM');
}
parent::display();
}
}
Thanks