editor fields

editor fields

aimericaimeric Posts: 5Questions: 2Answers: 0

hi,
i've a field type "select" in index.php, with leftjoin in staff.php and i've limit dropdown list where id == 2.
if you have a solution. thx.
code:

fields: [ 
{
label: "Presta:",
name: "exp_add.Presta",
type: "select",
placeholder: "Selection Presta",
def: function ( data ) {
    if (data == 2){ 
        return data;
        }
    }
}
]

Answers

  • allanallan Posts: 63,871Questions: 1Answers: 10,525 Site admin

    I'm afraid I'm not entirely certain what your question is.

    If you are using the Editor PHP or .NET libraries then there are options that can be used to provide conditions for the options to show in the list, and also to limit their length - that documentation is available here.

    Allan

  • aimericaimeric Posts: 5Questions: 2Answers: 0

    Hi,
    How to put a condition on the rolling list?

    thx

  • allanallan Posts: 63,871Questions: 1Answers: 10,525 Site admin

    The documentation I linked to includes information about the Where() method of the Options class which can be used to add a condition to the list of options to be shown in the select element,which is what I presume you mean by "rolling list".

    Allan

  • aimericaimeric Posts: 5Questions: 2Answers: 0

    Yes,
    i use
    ->where( 'exp_presta.Zone',$idZone,'=')
    in staff.php but my select is complete.

    thx

  • allanallan Posts: 63,871Questions: 1Answers: 10,525 Site admin

    Do you also add that to the Options class. e.g. this is the example in the documentation I linked to:

    Field::inst( 'users.site' )
        ->options( Options::inst()
            ->table( 'sites' )
            ->value( 'id' )
            ->label( 'name' )
            ->where( function ($q) {
                $q->where( 'name', 'L%', 'LIKE' );
            }
        );
    

    Allan

This discussion has been closed.