Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

CategoryUsed withRoutineReturn value
Single value fieldsTEXT, TEXT_AREA, SELECT_LIST, RADIO_GROUP, SINGLE_CHECKBOX(optional)BA_getSingleValue(argv, label)String representing the value entered or the selected option for the given label. For checkbox it will return "checked" if the checkbox was selected or an empty string otherwise.
Multi value fieldsMULTI_SELECT_LIST, CHECKBOX_GROUPBA_getMultiValues(argv, label)String array representing the selected options.
FILE_UPLOADString array containing pairs of original filename and uploaded path. Even indices will contain original filenames, while odd indices will contain uploaded path. See Examples for usage.
CheckboxSINGLE_CHECKBOXBA_isChecked(argv, label)Convenience method for checking whether a checkbox is selected or not. Returns a boolean: true if the box was checked, false otherwise.

...

Generic errors show up in the upper part of the screen, as demonstrated below.

Image RemovedImage Added

To do this, all you have to do is return the error message. Like this:

...

If you have multiple input fields on the screen, it would be nice to validate them all at once and show errors for each one.

Image RemovedImage Added

To do this, you will have to return an array containing pairs of label and error. 

Code Block
string fruitLabel = getElement(argv, 0);
string fruit = getElement(argv, 1);

string chocolateLabel = getElement(argv, 2);
string chocolate = getElement(argv, 3);

string [] errors;

if( isNull(fruit) ){
 	errors = addElement(errors, fruitLabel);
	errors = addElement(errors, "What? You don't like fruits?");
}

if( chocolate != "yes" and chocolate != "of course"){
	errors = addElement(errors, chocolateLabel);
	errors = addElement(errors, "No way!");
}

return errors;

Examples

Example 1

Iterating over uploaded files

Code Block
string [] files = BA_getMultiValues(argv, "file");
for(int i = 0; i < size(files); i+=2){
 number ORIGINAL_NAME = i;
 number NEW_PATH = i + 1;
 desc += "File " + files[ORIGINAL_NAME] + " was uploaded to " + files[NEW_PATH] + "\n";
}