about widget client script

jieLian123
Tera Expert

I am using widget to create request button in record producer.

but when commit the data ,

I tried to use g_form.submit. but it seems nothing got committed.

ps: I got the g_form object by using 「var g_form = $scope.page.g_form;」

 

5 REPLIES 5

jieLian123
Tera Expert

BTW, I am client script for your reference:

 

 

api.controller=function($scope) {
/* widget controller */
var c = this;
c.uiAction = function(action) {
var flag = inputCheck(g_form);
if(action == 'confirm'){
//doSomething
}else if(action == 'apply' && flag){
g_form.submitted = true;
g_form.submit();
}
}
}
g_form.submitted = false;
}else if(action == 'apply' && checkResult){
g_form.submitted = true;
g_form.submit(); //it is not working properly here.
}

Jagadish Sanadi
Kilo Sage

Hello @jieLian123 

 

Please share full code 

HTML:

<div class="panel panel-default">
 <div class="panel-body" >
 <button type="button" class="btn btn-primary" ng-click="c.uiAction('confirm')">確認</button>
 <button type="button" class="btn btn-secondary" ng-click="c.uiAction('apply')">申請</button>
 </div>
</div>

 

Client script:

 


api.controller=function($scope) {
  /* widget controller */
  var c = this;
 c.uiAction = function(action) {
    if ($scope.page.g_form) {
		 var g_form = $scope.page.g_form;
		 var flag = inputCheck(g_form,action);
	  }
	 }
	
function inputCheck(g_form,action) {
        var checkResult = true;//this is a just a flg for test.
	if(action == 'confirm'){
		if(checkResult){
			g_form.addInfoMessage('エラーがありません。');
		}
		g_form.submitted = false;
	}else if(action == 'apply' && checkResult){
		g_form.submitted = true;
		g_form.submit();
	}
	
	return checkResult;
}
}

and I didn't set the Server side  script.

Hello @jieLian123 

 

Try below code

api.controller = function($scope) {
/* widget controller */
var c = this;

c.uiAction = function(action) {
if ($scope.page && $scope.page.g_form) {
var g_form = $scope.page.g_form;
var flag = inputCheck(g_form, action);
}
};

function inputCheck(g_form, action) {
var checkResult = true; // Assuming this is a just a flg for test.
if (action == 'confirm') {
if (checkResult) {
g_form.addInfoMessage('エラーがありません。');
}
g_form.submitted = false;
} else if (action == 'apply' && checkResult) {
g_form.submitted = true;
g_form.submit();
}

return checkResult;
}
};