Ash FrameworkAF
Ash Framework3y ago
56 replies
WIGGLES

Ash Form Questions

Are there any gotchas with AshPhoenix.Form.create_for and child resources inside an inputs_for? I'm getting an unkown error and I'm not sure what's going wrong because the example in the documentation seems to indicate that the child object in a has_many relationship just gets created?
resource |>
Form.for_create(action,
            api: api,
            forms: forms,
            prepare_source: prepare_source
          )
forms={[
        answers: [
          type: :list,
          resource: PollAnswer,
          create_action: :create
        ]
      ]} 

<fieldset>
        <legend>Answers</legend>
        <.inputs_for :let={f_answer} field={f[:answers]}>
          <.input field={f_answer[:label]} label="Label" />
          <.icon
            phx-click="remove_form"
            phx-value-path={f_answer.name}
            phx-target={"##{@id}"}
            name="hero-minus"
          />
        </.inputs_for>
        <menu>
          <.icon
            phx-click="add_form"
            phx-value-path={f[:answers].name}
            phx-target={"##{@id}"}
            name="hero-plus"
          />
        </menu>
</fieldset>

My guess is that there's something I need to opt into configuration wise in the resource to ahve this work?
Was this page helpful?