This topic is locked
[SOLVED]

How to access list page fields when using a Custom Validation Plugin

2/17/2024 10:37:35 AM
PHPRunner General questions
K
kelgate author

Hi again,

From an earlier thread in which I needed to validate one or more fields in a List page, I have run into difficulties in getting values from other fields in the relevant row.

Each row in the list has upto five Competition Round Score values as well as a Maxiumum Score value.

It seems to me that the neatest and most convenient way of making sure that none of the five Round Scores exceed the Maximum is to use a Custom Validation Plugin.

The problem arises when I need to get the Maximum Score value for a row (they can differ from row to row).

The code I am trying out is:

*function scorevalidate(sVal)
{
var ctlMaxTxt = row.getFieldText("maxscore");
var ctlMaxInt = parseInt(ctlMaxTxt) || 0;
if(sVal > ctlMaxInt)
return 'Score must not be greater than maximum';
else
return true;

}*

but this doesn't work. If I just put a fixed value into ctlMaxInt it works fine, but since the maximum score can vary row-by-row this isn't an option.

I haven't tried setting the score value to zero from this function either, but it is something I'd also like to be able to do.

Thanks again

Kelvin

admin 2/18/2024

It is not supposed to have access to list page fields. Validation plugins work on Add/Edit pages and not aware of List page data.

K
kelgate author 2/18/2024

Thanks Admin,

I used the wrong term when stating it was a list page.

What I am really performing is an inline edit, both in a "standard", click the edit symbol page as well as a spreadsheet version.

I guess I called it a list page because it displays a "list" of records rather than being a single record edit page.

Would my approach still work in the inline/spreadsheet variants?

admin 2/19/2024

I understand what you saying. Editing always happening in the context of the Edit page ( or Add page if you perform Inline Add ).

In either case, Validation Plugins are not expected to have access to other fields values. What you can use, for instance, are Field Events. You can trigger a field event when the focus leaves any field ( blur event ) and check other field values there.

https://xlinesoft.com/phprunner/docs/field_events.htm
https://xlinesoft.com/phprunner/docs/how_to_access_fields_in_the_field_events.htm

K
kelgate author 2/20/2024

Thanks.

I'll have to use the Field Event option then.

Not as neat as Validation Plugins and more duplicate code, but it will accomplish what I need.

Thanks again for your help.