Programming Phoenix LiveView: Accessing Changeset in form {page 199}

Similar to other post, need to access and assign changeset differently:

        <.input
        field={@changeset[:gender]}
        type="select"
        label="Gender"
        options={["female", "male", "prefer not to say"]}/>

        <.input
        field={@changeset[:year_of_birth]}
        type="select"
        label="Year of birth"
        options={Enum.reverse(1920..2023)}/>

        <.input
        field={@changeset[:user_id]}
        type="hidden"/>
  defp assign_changeset(
         %{
           assigns: %{
             demographic: demographic
           }
         } = socket
       ) do
    assign(socket, :changeset, to_form(Survey.change_demographic(demographic)))
  end

Yep, you’re on the right track here! This and all other form code will be updated in the next book release which we’re working on now. Thanks for your patience!