...
Category | Used with | Routine | Return value |
---|---|---|---|
Single value fields | TEXT, 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 fields | MULTI_SELECT_LIST, CHECKBOX_GROUP | BA_getMultiValues(argv, label) | String array representing the selected options. |
FILE_UPLOAD | String 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. | ||
Checkbox | SINGLE_CHECKBOX | BA_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.
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.
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";
} |