validator blocks update
validator blocks update
Hi,
I am having this update-function for rows:
$('#liste_freigaben').on('change', 'input.editor-active', function () {
let now = new Date().toISOString().split('Z');
editor_freigaben
.edit($(this).closest('tr'), false)
.set({
'V_Freigaben.freig_erledigt': $(this).prop('checked') ? 1 : 0,
'V_Freigaben.freig_erledigt_durch': __thisPID__,
'V_Freigaben.freig_erledigt_wann': now.length ? now[0] : '' }
)
.submit();
this does work, but when this validator is active:
Field::inst( 'V_Freigaben.freig_person' )
->options( Options::inst()
->table( 'V_NeueFreigeber' )
->value( 'PID' )
->label( 'NamePers' )
->where( function ( $q ) use ( $selectedStapelname, $selectedINP_ID ) {
$q->where( 'Stapelname', $selectedStapelname )
->and_where( function ( $r ) use ( $selectedINP_ID ) {
$r->where( 'INP_ID', $selectedINP_ID );});
} )
)
->validator( Validate::minNum( //this causing the problem!!!!
1,
'.',
ValidateOptions::inst()
->message( 'Freigeber muss ausgewählt werden' )
->allowEmpty( false )
->optional( false )
) ),
it is blocked with the error shon in the message-box. As he is picking a already existing line, there must be a "freig_person", therefore the validator should not be a problem?
Thanks
Max
This question has accepted answers - jump to:
Answers
Hi Max,
Can you show me the request data that is being sent to the server please? You can find that in the network inspector's "Headers" or "Request" tab (depending on what browser you are using).
Thanks,
Allan
sure - thanks!
so it seems it does not find the freig_person, although this is defined in the editor as field:
but the problem was that the column looked like that:
I now added a column
and now it works - thanks!
Max
Hi Max,
Super - great to hear it works now
Allan
strange....it did again stop working. I also checked with other rows, they are also not defined as a column, but only in the editor
Any further ideas you have got what could cause this?
Are you inline editing perhaps? By default it will submit only the value that has changed, and since you have the validator marked as requiring that a value be submitted for that field, if you edit another field, the validator would fail.
One option to address that (if it is the case) would be to submit the full row of data rather than just the changed value.
The other option is to allow the
optional
option for the validator.Allan
yes, this is inline editing. It seems strange to me, that other (unchanged and not visible/existing) columns like Stapelname or INP_ID are sent with the "old" value - only the freig_person is missing.
I tried adding
in this function
But this "kills" it completely, then there is no action reported in the network-inspector at all.
Are you able to PM me a link to the page so I can debug it?
Allan
Hi Allan,
did some more resear ch myself...
This works for some rows, but not for all
The reason must be somewhere here:
for me it does not makes sense, but as soon as V_NeueFreigeber.NamePers is NULL (no hit in this table), the program doe not send the "V_Freigaben.freig_person", although there always is a value.
I have now found a way around by changing V_NeueFreigeber so there always has to be a hit - still I do not understand why this happened....
Thanks
Max