How to include field values in the vtypes message text for vtype validation in forms? - forms

I'm working on form validation and I have used Vtypes to check number ranges.
It's all working fine, except I need to include my own allowed values ( field.minValField and field.maxValField) in the 'numberrangeText'. Is there any way to do that ?
Thanks in advance
Ext.apply(Ext.form.VTypes, {
numberrange : function(val, field) {
if(val < field.minValField || val > field.maxValField){
console.log(field);
return false;
}
},
numberrangeText: 'Value Range Should Be: '
});
Arfeen

There is no way to use templates or XTemplates in numberrangeText. Because they(extjs) just take this string without changes as I've found out from file src/widgets/form/TextField.js from the line errors.push(this.vtypeText || vt[this.vtype +'Text']);.
But as you can see you can use field.vtypeText instead.
For example you can write something like this:
field.vtypeText = 'Value Range Should Be: ' + field.minValField + '-' + field.maxValField;
in your numberrange function.
You can see what I'm talking about in this example

Related

cant translate text with value using GETX in flutter

the problem is that the text has value which declares the day before the text
so idk how to translate this text that includes value.
untilEventDay =
'${pDate.difference(DateTime.now()).inDays},days/ until event day'
.tr;
in translation page :
,days/ until next event day': 'ڕؤژ ماوه‌/ تاوه‌كو ئیڤێنتی داهاتوو',
you should separate the value's string from your translation
var eventDayCountDownTitle = '${pDate.difference(DateTime.now()).inDays}' + ',' + days/ until event day'.tr;
and if you need your day number to be in a specific language, you can use a map or a helper method. map solution would be something like this:
Map<String,String> englishToPersianNumber = {'1' : '۱'}
and then use it in your string :
englishToPersianNumber[pDate.difference(DateTime.now()).inDays.toString()]
Important: to have a cleaner code, you can create a helper method to generate your desired string, and call it in your text widget. the code would be more understandable that way. Also, you can add handle any conditions that may later be added to the string generator. like if it's the last day, write something else instead of 0 days remaining.
String eventDayCountDownTitle(int remainingDays) {
if(remainingDays == 0) return "Less than One day to the event".tr;
return '${remainingDays.toString}' + ',' + 'days/ until event day'.tr;
}
ps. your question's title is wrong, you should change it to what you're explaining in the caption

how to add a sign like dollar to the end of input value of Gravity Forms entry after submition

I need an input type for percentage input which will add the % sign at the end of the user input and also an input type for currency without the text of currency(CAD, USD, ...). I just need a $ sign
and I also use a PDF maker for gravity forms that I need the Correct Values to be printed in both pdf and email with sign
I tried gform_after_create_post_39 and gform_pre_submission_39 which 39 is the id of the form
This is the code :
add_action( 'gform_after_submission_39', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
if(isset($_POST['input_16']) && !empty($_POST['input_16'])) {
$_POST['input_16'] = $_POST['input_16'] . ' %';
}
if(isset($_POST['input_17']) && !empty($_POST['input_17'])) {
$_POST['input_17'] = $_POST['input_17'] . ' $';
}
}
I need to add % sign at the end of input_16 value in email and PDF
and also I need to add $ sign to the end of input_17's value in the email and PDF
i tried to echo $_POST['input_16'] or $_POST['input_17'] the output is correct but it is not effected in email and PDF
The problem is solved. here is the Answer :
I added a simple Text input to the form and then by using this code
I can change the specific input value or update it by adding the sign at the end of an entry before notification send
'gform_pre_submission_39' -> 39 is the ID of the form that I want to change its input value
'input_130' -> is the simple text input with id 130 that I need to add % to the end
This hook will perform before Notification and after Form Validation!
So the changes will apply on PDF and email!
in the beginning, the problem was from the input which was number format so when I added % or $ sign to the end of the entry after the form submission it didn't accept because it was number format.
sorry for my English, I hope I could help someone who has such a problem in the future
add_action( 'gform_pre_submission_39', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
// INPUT 130 - Basic Coverage
if(isset($_POST['input_130']) && !empty($_POST['input_130'])) {
if(strpos($_POST['input_130'], '%') == false) {
$_POST['input_130'] = $_POST['input_130'] . '%';
} else {
//Do Nothing
}
}
if(isset($_POST['input_131']) && !empty($_POST['input_131'])) {
if (strpos($_POST['input_130'], '$') == false) {
$_POST['input_131'] = $_POST['input_131'] . '$';
} else {
//Do Nothing
}
}
}

How can I compare message type string value

I am capturing var TRANSACTION_TYPE =msg['MSH'].['MSH.9'].['MSH.9.2'].toString();
Now I want to check if this value is not equal to A40, like
if ( TRANSACTION_TYPE!=='A40') {
--
--
}
But it is not working
Thanks
Seems like it should work. The !== is looking that the variable type is a string as well so that is something to look out for. An easy way to debug issues like this is using either the channelMap or logger.info() for debugging. So I'd advise these lines before your 'if':
logger.info('Debug: typeof(TRANSACTION_TYPE): ' + typeof(TRANSACTION_TYPE));
logger.info('Debug: TRANSACTION_TYPE: ' + TRANSACTION_TYPE);
logger.info('Debug: TRANSACTION_TYPE logic: ' + (TRANSACTION_TYPE !== 'A40'));

GravityForms - calculate two fields into a percentage

Hello stack exchange community,
Is it possible to use the internal gravity forms calculate fields function to calculate it into a percentage? I can't find where in the code this calculation happens so i can rewrite how the field outputs. Can anyone point me in the correct direction (as in what hook can i use to rewrite how a form field outputs)?
You'll want to use the "gform_calculation_format_result" JS filter. Copy, paste, and configure the following code in an HTML field on your form.
<script type="text/javascript">
gform.addFilter( 'gform_calculation_format_result', function(formattedResult, result, formulaField, formId, calcObj ) {
// UPDATE: "3" to ID of your Calculation field
if ( formulaField.field_id == 3 ) {
formattedResult = gformFormatNumber( result, ! gformIsNumber( formulaField.rounding ) ? -1 : formulaField.rounding, '.', ',' ) + '%';
}
return formattedResult;
});
Here's an export of a working form if you'd like to import and see this in action (form export).

jqgrid edittype select load value from data

I am using jqgrid in my new project.
In a specific case I need to use a select element in the grid. No problem.
I define the colModel and the column for example like (from wiki)
colModel : [
...
{name:'myname', edittype:'select', editoptions:{value:{1:'One',2:'Two'}} },
...
]
But now when I load my data I would prefer the column "myname" to contain the value 1.
This won't work for me instead it has to contain the value "One".
The problem with this is that the text-part of the select element is in my case localized in the business layer where the colModel is dynamically generated. Also the datatype for the entity which generates the data via EF 4 may not be a string. Then I have to find the correct localized text and manipulate the data result so that the column "myname" does not containt an integer which is typically the case but a string instead with the localized text.
There is no option you can use so that when the data contains the value which match an option in the select list then the grid finds that option and presents the text.
Now the grid presents the value as a text and first when I click edit it finds the matching option and presents the text. When I undo the edit it returns to present the value again.
I started to think of a solution and this is what I came up with. Please if you know a better solution or if you know there is a built in option don't hesitate to answer.
Otherwise here is what I did:
loadComplete: function (data) {
var colModel = grid.getGridParam('colModel');
$.each(colModel, function (index, col) {
if (col.edittype === 'select') {
$.each(grid.getDataIDs(), function (index, id) {
var row = grid.getRowData(id);
var value = row[col.name];
var editoptions = col.editoptions.value;
var startText = editoptions.indexOf(value + ':') + (value + ':').length;
var endText = editoptions.indexOf(';', startText);
if (endText === -1) { endText = editoptions.length; }
var text = editoptions.substring(startText, endText);
row[col.name] = text;
grid.setRowData(id, row);
});
}
});
}
It works and I will leave it like this if nobody comes up with a better way.
You should just include additional formatter:'select' option in the definition of the column. See the documentation for more details.