talonframework / talon

An app builder framework for Phoenix
MIT License
164 stars 9 forks source link

Add support for input of array of strings, with textarea having each line as separate entry in array #102

Closed hubert-b7 closed 6 years ago

hubert-b7 commented 6 years ago

I needed to have an input for array of strings. Figured the simplest way to do it for now is to have textarea where each entry is a separate line.

In order to update the field with one more entry you need to add new line to textarea, for example if a model has 3 values in array: value1, value2, value3, the rendered textarea will have the following value:

value1 value2 value3

To add / remove / change entries you just change appropriate lines.

In order for this to work, the corresponding model is responsible of casting fields of type {:array, :string} from string to array in it's changeset/2 function.