The join field must be included as a regular field in the Editor instance. error

The join field must be included as a regular field in the Editor instance. error

ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4

Hey Allan.

Im performing this join :

$this->editor_instance->join(
    Mjoin::inst( 'general_data_countries' )
    ->link('publishers_offers_feed.publisher_original_offer_id,offers_target_geos.offer_id')
    ->link( 'general_data_countries.iso_2_letter_code,offers_target_geos.country_id')
    ->order( 'name asc' )
    ->fields(
        Field::inst( 'iso_2_letter_code' )
        ->validator( 'Validate::required' )
        ->options( 'general_data_countries,iso_2_letter_code,name' ),
        Field::inst(  'name' ))
);

this my json to init the table fields:

[
  {
    "label": "Geos",
    "name": "general_data_countries[].iso_2_letter_code",
    "type": "select2",
    "opts": {
      "placeholder": "Select Geos",
      "multiple": true,
      "allowClear": true
    }
  }
]

but i get this error:

DataTables warning: table id=publishers_offers_feed - Join was performed on the field 'publisher_original_offer_id' which was not included in the Editor field list. The join field must be included as a regular field in the Editor instance.

what did i miss?

tanks :)

Answers

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

    This looks wrong:

    ->link('publishers_offers_feed.publisher_original_offer_id,offers_target_geos.offer_id')
    

    It should be passing in two strings to the function - not a single one:

    ->link('publishers_offers_feed.publisher_original_offer_id', 'offers_target_geos.offer_id')
    

    Likewise with the second link call.

    Allan

  • ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4
    edited February 2018

    Hi Allan

    yeah i just echo it wrong... but the issue is still the same.
    this is my code:

    ->link('publishers_offers_feed.publisher_original_offer_id', 'offers_target_geos.offer_id')
    

    When i debug the query i see they query runs good and bring results, but something in the UI have some missmatch with the table fields...

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

    In that case, the error suggests that publishers_offers_feed.publisher_original_offer_id is not included in the field list in the parent table's fields.

    Allan

  • ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4

    mmmmm but i can see it when i print the editor fields:

    Array
    (
        [1] => Array
            (
                [type] => select
                [label] => Publisher ID
                [name] => publishers_offers_feed.publisher_id
            )
    
        [2] => Array
            (
                [label] => Publisher Feed ID
                [name] => publishers_offers_feed.publisher_feed_id
            )
        [3] => Array
            (
                [label] => Geos
                [name] => general_data_countries[].iso_2_letter_code
                [type] => select2
                [opts] => Array
                    (
                        [placeholder] => Select Geos
                        [multiple] => 1
                        [allowClear] => 1
                    )
    
            )
    
    )
    
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Can you show me your full PHP code please?

    Thanks,
    Allan

  • ziv@kpmbro.comziv@kpmbro.com Posts: 73Questions: 28Answers: 4
    $this->editor_instance->join(
        Mjoin::inst( 'general_data_countries' )
        ->link('publishers_offers_feed.publisher_original_offer_id','offers_target_geos.offer_id')
        ->link( 'general_data_countries.iso_2_letter_code','offers_target_geos.country_id')
        ->order( 'name asc' )
        ->fields(
            Field::inst( 'iso_2_letter_code' )
            ->validator( 'Validate::required' )
            ->options( 'general_data_countries','iso_2_letter_code','name' ),
            Field::inst(  'name' ))
    );
    $this->editor_instance->process($p);
    $data = $this->editor_instance->data();
    echo json_encode( $data );
    
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    I'm afraid I don't see where the publishers_offers_feed.publisher_original_offer_id field is defined in the editor_instance there.

    Allan

This discussion has been closed.