Make select-type field temporarily "multiple" only for create

Make select-type field temporarily "multiple" only for create

BalubaerBalubaer Posts: 16Questions: 2Answers: 0

Hi,

I'm looking for a way to handle the following situation:

I have a table including select fields which only allow one value (default behavior) by design. But for the creation of new entries/rows I wan't to extend the default create form to allow a multiple selection on a select field (and converting the multiple selection to new rows with the same values on all other fields but only one of each value of the multiple select field).

My idea is now to catch the "initCreate" event and change the form field to allow multiple selections (temporarily). The form data will then be converted to "each row"-data within the "preSubmit" event.

My question is now, how to access and change the field options temporarily and if this will be one correct way to do?

Thanks in advance,
Dennis

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin
    Answer ✓

    Hi Dennis,

    What you would need to do is use the add() and clear() methods to add and remove the field as required in the initCreate and initEdit events.

    It isn't currently possible to have the select field type dynamically morph between multi and single.

    If someone does select multiple fields on create, how would they be able to edit them later?

    Allan

  • BalubaerBalubaer Posts: 16Questions: 2Answers: 0

    Hi Allan,

    thanks for the info. I realized it in a very similar way.

    And to answer your "how to edit" question: the multiple select field will be "transformed" on preSubmit to multiple created rows with one single value of this "multi select" field selections. ;)

    Dennis

This discussion has been closed.