Editor: - Is there an option to exclude fields from the select query?

Editor: - Is there an option to exclude fields from the select query?

borconiborconi Posts: 56Questions: 19Answers: 1

I have some fields which I need to handle separately in editor, and Events is the perfect way to do this, however I do need to display some options to the user, but the option is outside the table and I cannot create a join because it just doesn't work in this scenario, so I was wondering if there is any way exclude a field from the select query?

Let me illustrate it with an example:

Server side:

->fields(
        Field::inst( 'company.Name' ),
        Field::inst( 'stores.company_id' )->options( 'company', 'id', 'Name', function ($q) {
                                    global $owner;
                                    $q->where('owner',$owner);})
                                    ->validator( 'Validate::dbValues' ),
        Field::inst( 'stores.short_add' ),
        Field::inst( 'stores.add1' ),
        Field::inst( 'stores.add2' ),
        Field::inst( 'stores.postcode' ),
        Field::inst( 'stores.s_n' ),
        Field::inst( 'freq_type' )->validator( 'Validate::numeric' )->options( function () {
                    return array(
                    array( 'value' => '0', 'label' => 'Interval' ),
                    array( 'value' => '1', 'label' => 'Set Date' )
                    );})->set(false),

//the column freq_type does not exist in the stores table and I'm going to handle it myself in an Events function, however when the client creates fields I like to show this as an option.


        Field::inst( 'stores.owner' )->setValue($owner)
    )
    ->leftJoin( 'company', 'stores.company_id', '=', 'company.id' );
    $editor->where('stores.owner',$owner);

An important note, in this scenario, I'm showing the user data from one table and allow him to create new entries in different tables, the table he is actually viewing is not going to be modified at all, if that makes sense.

Also is it allowed to set all the fields to false? Meaning none of them will be updated when data is submitted, again I'm going to handle that in a custom Event.

Thank you

This question has an accepted answers - jump to answer

Answers

  • borconiborconi Posts: 56Questions: 19Answers: 1
    edited October 2016 Answer ✓

    So I'm answering my own question, yes it is possible, need to use ->get(false); for the fields which needs to be excluded from the query.

This discussion has been closed.