This topic is locked
[SOLVED]

Dialog api - Params dynamically

10/1/2021 1:14:19 AM
PHPRunner General questions
Myr0n author

Hello everybody

I need some help please.

I want to show a Dialog using the Dialog api, sometimes will havethis Dialog 2 fields others 3 or 4 fields, for the moment I have a condition that will show a different dialog in every scenario unfortunately for me the scenarios are growing up and I think that the only way is to create dynamically the params for the dialog, somebody have an example how to do it and share with me please.
Thank you so much

Myr0n author 10/1/2021

Found the solution, here it is.

/* Fields declaration */
MyFields = [];
MyFields.push(
{
name: 'subject',
label: 'Subject for email',
type: 'text',
value: '',
required: true
});

MyFields.push(
{
name: 'body',
label: 'Message body 2',
type: 'textarea',
value: 'Hello,\n'
});

ctrl.dialog(
{
title: 'This is my Title',
height: 370,
prefix: 'dialogHelper',
fields: MyFields,
ok: Runner.getCustomLabel('ACCEPT_BUTTON'),
cancel: '<B>'+Runner.getCustomLabel('CANCEL_ANSWER')+'</B>',
afterCreate: function( popup, controls ){
$("#dialogHelper_button_cancel").removeClass('btn btn-default').addClass('btn btn-danger');
$("#dialogHelper_button_ok").removeClass('btn btn-primary').addClass('btn btn-success');
},
beforeOK: function( popup, controls ) {
var result1 = controls[0].val(); //MU2GITouchIdTemp
var result2 = controls[1].val(); //TerrIsLost
if(result1 != null){
swal('Success', '[0] ' + result1 + '[2] ' + result2, 'success');
}
}
});
return false;