Input not valid

Input not valid

SWATswatSWATswat Posts: 109Questions: 0Answers: 0

Hello,

I encounter a strange phenomenon.
When I do an Update by Datatable Editor inline so directly in the table it works well.
But when I select the line to be modified and I click on Update (the Modal appears) I modify my line and I click on the update button, I get an error message: Input not valid.

Console :
Requete :

        
    action  "edit"
    data[row_17][r_i_d_a][id]   "17"
    data[row_17][r_i_d_a][perimetre]    "3"
    data[row_17][r_i_d_a][clients]  "13"
    data[row_17][r_i_d_a][activite] "1"
    data[row_17][r_i_d_a][date_decision]    "2019-02-22"
    data[row_17][r_i_d_a][i_d_a]    "A"
    data[row_17][r_i_d_a][problemes]    "DATAMATRIX+Traçabilité++produit,+POKA+YOKE+mélange+réf,+manquant+pièces"
    data[row_17][r_i_d_a][criticite_rida]   "1"
    data[row_17][r_i_d_a][solutions]    "Modification+des+MOP+"
    data[row_17][r_i_d_a][date_deadline]    "2019-03-31"
    data[row_17][r_i_d_a][etat_avancement]  "-505"
    data[row_17][r_i_d_a][status]   "5"
    data[row_17][r_i_d_a][etat] "1"
    data[row_17][r_i_d_a][users]    "1"
    data[row_17][r_i_d_a][commentaire]  "Attente+retour."
    data[row_17][r_i_d_a][date_realisation] ""
    data[row_17][r_i_d_a][date_verification]    ""
    data[row_17][r_i_d_a][resultat] ""

Response :

    
    fieldErrors [ {…} ]
    0   Object { name: "r_i_d_a.id", status: "Input not valid" }
    name    "r_i_d_a.id"
    status  "Input not valid"
    data    []

View : {"fieldErrors":[{"name":"r_i_d_a.id","status":"Input not valid"}],"data":[]}

L'update not work !

But the same operation by InLine Editor :
Console :
Requete :

    action=edit&data%5Brow_17%5D%5Br_i_d_a%5D%5Bcommentaire%5D=Attente+retour+Client.

Response :

    
    data    [ {…} ]
    0   Object { DT_RowId: "row_17", r_i_d_a: {…}, perimetre_rida: {…}, … }
    DT_RowId    "row_17"
    r_i_d_a Object { perimetre: "3", clients: "13", activite: "1", … }
    perimetre   "3"
    clients "13"
    activite    "1"
    date_decision   "2019-02-22"
    i_d_a   "A"
    problemes   "DATAMATRIX Traçabilité produit, POKA YOKE mélange réf, manquant pièces"
    criticite_rida  "1"
    solutions   "Modification des MOP "
    date_deadline   "2019-03-31"
    id  "17"
    etat_avancement "-505"
    status  "4"
    etat    "1"
    users   "1"
    commentaire "Attente retour Client."
    date_realisation    null
    date_verification   null
    resultat    ""
    perimetre_rida  Object { nom_perimetre: "Reconditionnement" }
    nom_perimetre   "Reconditionnement"
    client_rida Object { nom_client: "XXX" }
    nom_client  "XXX"
    activite_rida   Object { nom_activite: "Automotive" }
    nom_activite    "Automotive"
    tech_compteur_modif_deadline    Object { compteur: null }
    compteur    null
    status  Object { nom_status: "Suspendu" }
    nom_status  "Suspendu"
    images  Object { nom_images: "OK" }
    nom_images  "OK"
    users_rida_egale_un Object { trigramme_users_rida: "OGR" }
    trigramme_users_rida    "OGR"

L'update work perfectly!

Do you have an idea please?

Thanking you.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    What validation are you using at the server-side for that field?

    Allan

  • SWATswatSWATswat Posts: 109Questions: 0Answers: 0

    Hello Allan,

    Here is the server-side file :

    Editor::inst( $db, 'r_i_d_a' )
        ->field( 
            Field::inst( 'r_i_d_a.perimetre' )
                ->options( Options::inst()
                    ->table( 'perimetre_rida' )
                    ->value( 'id_perimetre' )
                    ->label( 'nom_perimetre' )
                )
                ->validator( Validate::dbValues() ),
            Field::inst( 'perimetre_rida.nom_perimetre' ),  
            Field::inst( 'r_i_d_a.clients' )
                ->options( Options::inst()
                    ->table( 'client_rida' )
                    ->value( 'id_client' )
                    ->label( 'nom_client' )
                )
                ->validator( Validate::dbValues() ),
            Field::inst( 'client_rida.nom_client' ),
            Field::inst( 'r_i_d_a.activite' )
                ->options( Options::inst()
                    ->table( 'activite_rida' )
                    ->value( 'id_activite' )
                    ->label( 'nom_activite' )
                )
                ->validator( Validate::dbValues() ),
            Field::inst( 'activite_rida.nom_activite' ),
            Field::inst( 'r_i_d_a.date_decision' )
                ->validator( Validate::dateFormat( 'Y-m-d' ) )
                ->getFormatter( Format::dateSqlToFormat( 'Y-m-d' ) )
                ->setFormatter( Format::dateFormatToSql('Y-m-d' ) )
                ->getFormatter( function ( $val, $data, $opts ) { 
                    if ($val === "0000-00-00"){ echo ""; }else{ return date( 'Y-m-d', strtotime( $val ) ); } 
                    } ),
            Field::inst( 'r_i_d_a.i_d_a' ),
            Field::inst( 'r_i_d_a.problemes' ),
            Field::inst( 'r_i_d_a.criticite_rida' ),
            Field::inst( 'r_i_d_a.solutions' ),
            Field::inst( 'r_i_d_a.date_deadline' )
                ->validator( Validate::dateFormat( 'Y-m-d' ) )
                ->getFormatter( Format::dateSqlToFormat( 'Y-m-d' ) )
                ->setFormatter( Format::dateFormatToSql('Y-m-d' ) )
                ->getFormatter( function ( $val, $data, $opts ) { 
                    if ($val === "0000-00-00"){ echo ""; }else{ return date( 'Y-m-d', strtotime( $val ) ); } 
                    } ),
            Field::inst( 'r_i_d_a.id' )->set(false)
                ->options( Options::inst()
                    ->table( 'tech_compteur_modif_deadline' )
                    ->value( 'id_table_r_i_d_a' )
                    ->label( 'compteur' )
                )
                ->validator( Validate::dbValues() ),
            Field::inst( 'tech_compteur_modif_deadline.compteur' ),     
            Field::inst( 'r_i_d_a.etat_avancement' ),
            Field::inst( 'r_i_d_a.status' )
                ->options( Options::inst()
                    ->table( 'status' )
                    ->value( 'id_status' )
                    ->label( 'nom_status' )
                )
                ->validator( Validate::dbValues() ),
            Field::inst( 'status.nom_status' ),
            Field::inst( 'r_i_d_a.etat' )
                ->options( Options::inst()
                    ->table( 'images' )
                    ->value( 'id_images' )
                    ->label( 'nom_images' )
                )
                ->validator( Validate::dbValues() ),
            Field::inst( 'images.nom_images' ),     
            Field::inst( 'r_i_d_a.users' )
                ->options( Options::inst()
                    ->table( 'users_rida_egale_un' )
                    ->value( 'id_users_rida' )
                    ->label( 'trigramme_users_rida' )
                )
                ->validator( Validate::dbValues() ),
            Field::inst( 'users_rida_egale_un.trigramme_users_rida' ),
            Field::inst( 'r_i_d_a.commentaire' ),
            Field::inst( 'r_i_d_a.date_realisation' )
                ->validator( Validate::dateFormat( 'Y-m-d' ) )
                ->getFormatter( Format::dateSqlToFormat( 'Y-m-d' ) )
                ->setFormatter( Format::dateFormatToSql('Y-m-d' ) )
                ->getFormatter( function ( $val, $data, $opts ) { 
                    if ($val === "0000-00-00" || $val === "" || $val === NULL){ echo ""; }else{ return date( 'Y-m-d', strtotime( $val ) ); } 
                    } ),
                
                
            Field::inst( 'r_i_d_a.date_verification' )
                ->validator( Validate::dateFormat( 'Y-m-d' ) )
                ->getFormatter( Format::dateSqlToFormat( 'Y-m-d' ) )
                ->setFormatter( Format::dateFormatToSql('Y-m-d' ) )
                ->getFormatter( function ( $val, $data, $opts ) { 
                    if ($val === "0000-00-00" || $val === "" || $val === NULL){ echo ""; }else{ return date( 'Y-m-d', strtotime( $val ) ); } 
                    } ),
            Field::inst( 'r_i_d_a.resultat' )
        )
        ->leftJoin( 'users_rida_egale_un', 'users_rida_egale_un.id_users_rida', '=', 'r_i_d_a.users' )
        ->leftJoin( 'status', 'status.id_status', '=', 'r_i_d_a.status' )
        ->leftJoin( 'perimetre_rida', 'perimetre_rida.id_perimetre', '=', 'r_i_d_a.perimetre' )
        ->leftJoin( 'client_rida', 'client_rida.id_client', '=', 'r_i_d_a.clients' )
        ->leftJoin( 'activite_rida', 'activite_rida.id_activite', '=', 'r_i_d_a.activite' )
        ->leftJoin( 'images', 'images.id_images', '=', 'r_i_d_a.etat' )
        ->leftJoin( 'tech_compteur_modif_deadline', 'tech_compteur_modif_deadline.id_table_r_i_d_a', '=', 'r_i_d_a.id' )
        ->where('r_i_d_a.status', '1', '>=')
        ->where('r_i_d_a.status', '4', '<=')
        ->debug(false)
        ->process($_POST)
        ->json();
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thank you - so I can see you are using:

            Field::inst( 'r_i_d_a.id' )->set(false)
                ->options( Options::inst()
                    ->table( 'tech_compteur_modif_deadline' )
                    ->value( 'id_table_r_i_d_a' )
                    ->label( 'compteur' )
                )
                ->validator( Validate::dbValues() ),
    

    Given that it is marked as set(false) the validator shouldn't be running at all. Can you confirm for me that you don't actually want to set that value? If so, remove the validator.

    Regards,
    Allan

This discussion has been closed.