Skip to content
Snippets Groups Projects
Commit 9fe1cc4c authored by root's avatar root
Browse files

Fixes : Server side validation missed :: webform allowing to save without mandatory fields

parent 4cb8ccaf
No related branches found
No related tags found
1 merge request!1192Fixes : Server side validation missed :: webform allowing to save without mandatory fields
......@@ -41,10 +41,11 @@ class Settings_Webforms_Save_Action extends Settings_Vtiger_Index_Action {
if (!$fieldValue) {
$fieldValue = $fieldModel->get('defaultvalue');
}
if($fieldModel->isMandatory() && empty(trim($fieldValue))) {
throw new AppException(vtranslate('LBL_MANDATORY_FIELD_MISSING'));
}else if($fieldName == 'targetmodule' && !array_key_exists($fieldValue,$supportedModules)){
throw new Exception('Target module is not supported to create webform');
if($fieldModel->isMandatory() && empty(trim($fieldValue))){
$label = vtranslate($fieldModel->get('label'), $qualifiedModuleName);
throw new AppException(vtranslate('LBL_MANDATORY_FIELD_MISSING', 'Vtiger', $label));
} else if($fieldName == 'targetmodule' && !array_key_exists($fieldValue, $supportedModules)){
throw new Exception(vtranslate('LBL_TARGET_MODULE_IS_NOT_SUPPORTED_TO_CREATE_WEBFORM', 'Vtiger'));
}
$recordModel->set($fieldName, $fieldValue);
}
......@@ -57,6 +58,10 @@ class Settings_Webforms_Save_Action extends Settings_Vtiger_Index_Action {
$returnUrl = $recordModel->getModule()->getListViewUrl();
$recordModel->set('selectedFieldsData', $request->get('selectedFieldsData'));
$selectedFieldsData = $request->get('selectedFieldsData');
if (empty($selectedFieldsData)) {
throw new AppException(vtranslate('LBL_MANDATORY_FIELDS_MISSING', 'Vtiger'));
}
if (!$recordModel->checkDuplicate()) {
$recordModel->save();
$returnUrl = $recordModel->getDetailViewUrl();
......@@ -67,4 +72,4 @@ class Settings_Webforms_Save_Action extends Settings_Vtiger_Index_Action {
public function validateRequest(Vtiger_Request $request) {
$request->validateWriteAccess();
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment