A new record is not updated immediately in the table
A new record is not updated immediately in the table
When I create a new record (using a form), the record is created in a database, but it does not appear immediately on the table
(I only see it when I refresh the page)
When I create a new record (using a form), the record is created in a database, but it does not appear immediately on the table
(I only see it when I refresh the page)
The server code is
<?php
include( "lib/DataTables.php" );
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'business_owner')
->debug( true )
->fields(
Field::inst( 'id' ),
Field::inst( 'business_owner' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'A first name is required' )
) ),
Field::inst( 'job_id' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'A last name is required' )
) ),
Field::inst( 'sub_jobs' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'A last name is required' )
) ),
Field::inst( 'area' )
->validator( Validate::dbValues() ),
Field::inst( 'city' ),
Field::inst( 'genedr' ),
Field::inst( 'hot_job_or_not' )
->setFormatter( Format::ifEmpty(null) ),
Field::inst( 'date' )
->validator( Validate::dateFormat( 'd/m/Y' ) )
->getFormatter( Format::dateSqlToFormat( 'd/m/Y' ) )
->setFormatter( Format::dateFormatToSql('d/m/Y' ) ),
Field::inst( 'source' ),
Field::inst( 'contact_person' ),
Field::inst( 'city_location' ),
Field::inst( 'scope' ),
Field::inst( 'email' ),
Field::inst( 'name_rep' ),
Field::inst( 'job_info' ),
Field::inst( 'ID_number' ),
Field::inst( 'job_sub_id' ),
Field::inst( 'publish_on_others' ),
Field::inst( 'job_phone' ),
Field::inst( 'job_fax' ),
Field::inst( 'job_email' ),
Field::inst( 'bo_Name' ),
Field::inst( 'phone' ),
Field::inst( 'Mobile' ),
Field::inst( 'adress' ),
Field::inst( 'u_name' ),
Field::inst( 'u_password' ),
Field::inst( 'credit_owner_full_name' ),
Field::inst( 'credit_type' ),
Field::inst( 'credit_num' ),
Field::inst( 'cvv' ),
Field::inst( 'expire' ),
Field::inst( 'phone_to_credit_copmany' ),
Field::inst( 'comment' ),
Field::inst( 'owner_contact_person' )
)
->process( $_POST )
->json();
?>
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
Hi @chagold ,
It does that when the server response isn't returning the expected format. Please can you post what the server returns,
Cheers,
Colin
Which is why it isn't appearing in the table immediately. The debug (thanks for that) shows that the bound value of the
id
to fetch is an empty string, which in turn is whydata
is an empty array.In turn (again) you are setting
id
to be an empty string on the insert:I imagine that the database is overriding that, but the Editor libraries don't know that.
What is
id
- is it an auto sequence? Can you just not insert into it?Field::inst( 'id' )->set(false)
?Allan
Thank you!!