How can i push arrays into the Field::inst on load

How can i push arrays into the Field::inst on load

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

Hi

How can i add some data into the "data" object when loading the page from the server side(php)?

in this example i want to add to "filtering" array to the object.
something like that:

{
    data: ...
    draw: ...,
    recordsTotal: ...,
    recordsFiltered: ...,
    filtering: {
        "queue_status.task_name": [ 'ziv task', 'test', ... ],
        "queue_status.rabbit_queue_status": [ 'good', 'failed' ],
        ...
    }
}

so i could print the filters on "initComplete"

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,799Questions: 1Answers: 10,514 Site admin

    Are you using the Editor PHP libraries? If so, use the Editor->data() method rather than the Editor->json() method. The former will return an array that you can modify - e.g.

    $data = $editor->data();
    
    $data['filtering'] = ...;
    
    echo json_encode( $data );
    

    Allan

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

    Hey allan.

    yes i am using the Editor PHP libraries.
    my code is building the fields dynamic like this:

    $this->editor_instance->fields(Field::inst($fields_key));
    $this->editor_instance->fields(Field::inst($fields_key)->options( $table_name_to_join, 'id', $field_to_join ));

    i tried the data method and it didnt add to the object.
    $this->editor_instance->data(array("k"=>"v"));

    how can i to the "options" array?

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

    ahh i got it now, you right its working ! :)

    Thanks allan you saved me agin :))

This discussion has been closed.