Less than value in Editor validation breaks inline editing of other fields

Less than value in Editor validation breaks inline editing of other fields

bsukbsuk Posts: 92Questions: 26Answers: 2
edited March 2016 in Free community support

I've copied this example, as per https://editor.datatables.net/manual/php/validation :

Field::inst( 'last_name' )->validator( function ( $val, $data, $opts ) {
    return strlen( $val ) > 50 ?
        'Name length must be 50 characters or less' :
        true;
} )

However, when I try and change this to < 50, all other inline editing fields stop working (cannot save the value).
It seems as though Editor thinks the PHP is invalid, even though the function actually works on the field I'm applying it to.

I want to write a password validation function, but it seems as though any complexities in validator causes this strange problem where no other fields can be inline edited anymore.
Does anyone have any ideas as to how to troubleshoot this? There are no errors in the PHP log or on the page console.

Edit: It seems like any custom validation function, even client side with Jquery causes the other cells to no longer except inline editing.

Answers

  • bsukbsuk Posts: 92Questions: 26Answers: 2
    edited March 2016

    I've spent all day on this and still cannot see why I cannot apply either PHP or Javascript validation to my field. I've narrowed it down to be just affecting my "password" field.
    There's nothing that different about it, though validation seems to work on the other fields.
    Please help! What would cause inline editing to freeze up like that?! on all OTHER fields than the one I'm applying the validation to?!

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Hi,

    Are you seeing any Javascript errors occurring? If so - what are they?

    More importantly, what is the return from the server when the inline edit request is made? I'm "hoping" that there will be an error message there, or some kind of indicator of what the issue will be.

    Can you link to the page so I can debug it directly please.

    Allan

  • bsukbsuk Posts: 92Questions: 26Answers: 2
    edited March 2016

    Hi Allan, Many thanks for replying. However, I think I've figured out the problem the hard way (trial and error)!
    The problem was actually due to the existing database fields containing information that wouldn't pass the validators, for example, if the length requirement of a password field was 8, and my earlier test entries only had 3 characters, then inline editing of each other field for that row would fail, causing the "freezing" issue.
    I can only assume that upon inline editing of a field, validation is applied to the data in the entire row, causing a failure to be able to commit the changes, despite the data not changing on the fields that actually require validation.

    There were no javascript errors in the browser console, and no PHP errors in the Apache log. However, one thing that would be massively helpful would be to know how to capture the "return from the server". Is there an obvious way to debug data tables/PHP server output into a log somewhere? Is it a case of enabling verbose logging of Apache (or Datatables somehow)?

    I've requested purchase of full support for Editor (although my company is being slow), so hopefully you may be able to offer remote support into my environment in the future. It's currently quite difficult to provide an externally accessible test server (and datatables live doesn't have mysql support AFAIK).

    By the way, despite my struggles with Datatables (due to my own lack of coding knowledge), it's a fantastic product, so thanks very much for making it.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    I can only assume that upon inline editing of a field, validation is applied to the data in the entire row

    It is if it is configured that way (which it isn't by default). By default Editor will only submit the changed values from an inline edit, although that can be changed using the form-options object.

    one thing that would be massively helpful would be to know how to capture the "return from the server

    This tech note details how you can do that.

    it's a fantastic product

    Thank you :-)

    Allan

This discussion has been closed.