Add a field for many_to_many association data in the form

I have a post schema and a tag schema. post can have many tags. The two schemas are related through a many_to_many association. The join table between the two is named post_tags.

In my post create form, how can I create a tag field? I tried using inputs_for, but it doesn’t seem to work properly. I have not been able to figure out what is going wrong. I also want to make the tag field in the form a multiple selectable dropdown like here in elixir forum.

Any idea how to do this?

Maybe this post can help