Edit form shows a message "An error has occurred - Please contact the system administrator"

Edit form shows a message "An error has occurred - Please contact the system administrator"

Shane77Shane77 Posts: 4Questions: 0Answers: 0
edited September 2013 in Editor
Hi. I'm trying to make the datatable work.

The problem occurs on the Edit form when I click "Update" button:

- The Edit form doesn't close but instead shows an error message "An error has occurred - Please contact the system administrator".
- The datatable doesn't refresh.
- The record in DB is updated.

I checked the javascript console with IE and Chrome but no message... How could I know what causes this error message???

Test page:
http://beta.bizrebirth.com/marketing/campaign/index-test.html
(Please scroll to the right end and click on the "Edit" link in the datatable.)

PHP script:
[code]
include( "lib/DataTables.php" );

use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;

Editor::inst( $db, 'campaigns' )
->fields(
Field::inst( 'category_id' ),
Field::inst( 'name' ),
Field::inst( 'from_date' ),
Field::inst( 'to_date' ),
Field::inst( 'target_lead' ),
Field::inst( 'acquisition_lead' ),
Field::inst( 'budget' ),
Field::inst( 'cost' ),
Field::inst( 'remarks' )
)
->join(
Join::inst( 'mst_campaign_categories', 'object' )
->join( 'category_id', 'id' )
->fields(
Field::inst( 'name' )->name( 'category_name' )
)
)
->process( $_POST )
->json();
[/code]

Replies

  • Shane77Shane77 Posts: 4Questions: 0Answers: 0
    edited September 2013
    Sorry I could find a message in the console.

    [quote]
    Notice: Undefined index: mst_campaign_categories in /var/www/html/br/php/lib/Editor/Join.php on line 496

    {"id":"row_1","error":"","fieldErrors":[],"data":[],"row":{"DT_RowId":"row_1","category_id":"2","name":"test122345","from_date":"2013-08-30","to_date":"2013-08-31","target_lead":"100","acquisition_lead":"10","budget":"100","cost":"0","remarks":"test","mst_campaign_categories":{"category_name":"\u30e1\u30c7\u30a3\u30a2"}}}
    [/quote]

    It seems like it's trying to update the joined table as well although it isn't expected to be updated? By commenting out the line 496, it works fine, but I think there must be a way to avoid commenting out this line as I believe it would cause another problem.
  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Hi,

    Are you using the standard Editor PHP libraries?

    Also, could you confirm for me which DataTables account you used to purchase Editor so I can assign the license correctly please?

    Thanks,
    Allan
  • Shane77Shane77 Posts: 4Questions: 0Answers: 0
    edited September 2013
    I figured I needed to add ->table("tablename")->set(false)

    ->join( 'category_id', 'id' )
    ->table( 'mst_campaign_categories' )
    ->set( false )

    Now it works without modifying the Join class. Thanks!

    I kind of think it should be false by default...wondering how often multiple tables need to be updated.
  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Yes, I've been thinking of setting it to default false in 1.3.

    Could you confirm for me which DataTables account you used to purchase Editor so I can assign the license correctly please? Please feel free to PM me if you'd rather that way rather than in the public forum.

    Allan
  • Shane77Shane77 Posts: 4Questions: 0Answers: 0
    Hi Allan, I'm helping my client and they have purchased the license. I don't really want to bother them unless I absolutely have to. Thanks for your understanding.
  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Thanks for clarifying the situation!

    Allan
This discussion has been closed.