select field polpulated from database - empty value for edit mode

select field polpulated from database - empty value for edit mode

DagobertinaDagobertina Posts: 7Questions: 2Answers: 0

Hello everyone :smile:

I have a select field in my editor form which is populated with values from a database table (leftJoin). The user sees a description and selecting one of the descriptions saves the suitable id in the database table. That works fine with placeholder "please select" in create mode. Whenever the form for creating a new record is opened, the select field shows "please select" and you can leave it in that state. It is not required to select a value.

Of course it might happen, that a value is selected by mistake when creating a new record and later you want to correct this mistake by setting it to "please select" = empty value again, but in edit mode, the option / placeholder is not shown and you can't set it back to an empty value.

I think, the solution is somewhere here, but I can't figure out, how to implement this:
https://datatables.net/forums/discussion/43521

This is what I have so far:

                    {
                label: "Hilfe",
                name: "termine.id_hilfe",
                        type: "select",
                        placeholder: "Hilfe auswählen",
                        placeholderDisable: false,
                        placeholderValue: ''
                 },

and server-side:

        Field::inst( 'termine.id_hilfe' )                                       
          ->options( Options::inst()
            ->table( 'mitarbeiterstamm mitarbeiterstamm2' )      
            ->value( 'id_mitarbeiter' )                                         
            ->label( 'vorname' )                                                
          )
          ->validator( Validate::dbValues() ),

        Field::inst( 'mitarbeiterstamm2.vorname' ),

I could add an empty / 0-value to my database table "mitarbeiterstamm", but I think that's not an elegant solution. And somehow I feel, there is a better way :blush:

Many thanks for your help!

Best regards,
Tina

Answers

  • DagobertinaDagobertina Posts: 7Questions: 2Answers: 0

    omg

    Ashes on my head... o:)

    I had a typo... "placeholderDisable" instead of "placeholderDisabled"

    Sorry! I haven't seen that one working on that problem since yesterday and right now i checked everything again and saw it...

    Works like a charm now :)

Sign In or Register to comment.