Skip to content

Commit

Permalink
feat(Save) set default values for fields that are not given in quick …
Browse files Browse the repository at this point in the history
…create, filter fields forms, and web service create
  • Loading branch information
joebordes committed Apr 18, 2021
1 parent 3f57ef7 commit fafe91c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Smarty/templates/QuickCreateHidden.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-->*}

<form name="QcEditView" onSubmit="return getFormValidate();" method="POST" action="index.php" ENCTYPE="multipart/form-data">

<input type="hidden" name="savefromqc" value="1">
{if isset($FROM) && $FROM eq 'popup'}
<input type="hidden" name="from" value="{$FROM}">
<input type="hidden" name="return_action" value="Popup">
Expand Down
8 changes: 3 additions & 5 deletions include/Webservices/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ function vtws_create($elementType, $element, $user) {
}

foreach ($meta->getModuleFields() as $fieldName => $webserviceField) {
if ($webserviceField->getUIType() == 15 || $webserviceField->getUIType() == 16) {
$dval = $webserviceField->getDefault();
if (!isset($element[$fieldName]) && !empty($dval)) {
$element[$fieldName] = $dval;
}
$dval = $webserviceField->getDefault();
if (!isset($element[$fieldName]) && !empty($dval)) {
$element[$fieldName] = $dval;
}
}

Expand Down
9 changes: 8 additions & 1 deletion include/utils/CommonUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ function mkdirs($dir, $mode = 0777, $recursive = true) {

/**
* This function is used to set the Object values from the REQUEST values.
* @param object reference $focus - reference of the object
* @param object CRM object to fill with values
*/
function setObjectValuesFromRequest($focus) {
global $log;
Expand Down Expand Up @@ -1816,6 +1816,13 @@ function setObjectValuesFromRequest($focus) {
if (!empty($_REQUEST['cbuuid'])) {
$focus->column_fields['cbuuid'] = vtlib_purify($_REQUEST['cbuuid']);
}
if (!empty($_REQUEST['savefromqc']) || !empty($_REQUEST['FILTERFIELDSMAP'])) {
foreach (getFieldsWithDefaultValue(getTabid($moduleName)) as $fname => $fvalue) {
if (empty($focus->column_fields[$fname]) && !isset($_REQUEST[$fname])) {
$focus->column_fields[$fname] = $fvalue;
}
}
}
if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'EditView')) {
$cbfrommodule = $moduleName;
$cbfrom = CRMEntity::getInstance($cbfrommodule);
Expand Down

0 comments on commit fafe91c

Please sign in to comment.