= form_with model: [:provider_management, @provider, @external_user], url: provider_management_provider_external_user_path(@provider, @external_user), builder: GdsAdpFormBuilder do |f|

  = f.fields_for :user do |user_fields|
    = user_fields.govuk_error_summary

    = user_fields.govuk_text_field :first_name,
      label: { text: t('.first_name') }

    = user_fields.govuk_text_field :last_name,
      label: { text: t('.last_name') }

    = user_fields.govuk_email_field :email,
      label: { text: t('.email') }

    = user_fields.govuk_email_field :email_confirmation,
      label: { text: t('.email_confirmation') }

    = f.govuk_collection_check_boxes :roles,
      @external_user.available_roles,
      :to_s,
      :humanize,
      legend: { text: t('.roles'), size: 's' }

    - if @provider.chamber?
      = f.govuk_collection_radio_buttons :vat_registered,
        [['Yes','true'],['No','false']],
        :last,
        :first,
        legend: { text: t('.apply_vat'), size: 's' }

      = f.govuk_text_field :supplier_number,
        label: { text: t('.supplier_number') }

    = f.govuk_submit t(".submit.#{action_name}")

= form_with model: [:provider_management, @provider, @external_user], builder: GdsAdpFormBuilder do |f|

  = f.fields_for :user do |user_fields|
    = user_fields.govuk_error_summary

    = user_fields.govuk_text_field :first_name,
      label: { text: t('.first_name') }

    = user_fields.govuk_text_field :last_name,
      label: { text: t('.last_name') }

    = user_fields.govuk_email_field :email,
      label: { text: t('.email') }

    = user_fields.govuk_email_field :email_confirmation,
      label: { text: t('.email_confirmation') }

    = f.govuk_collection_check_boxes :roles,
      @external_user.available_roles,
      :to_s,
      :humanize,
      legend: { text: t('.roles'), size: 's' }

    - if @provider.chamber?
      = f.govuk_collection_radio_buttons :vat_registered,
        [['Yes','true'],['No','false']],
        :last,
        :first,
        legend: { text: t('.apply_vat'), size: 's' }

      = f.govuk_text_field :supplier_number,
        label: { text: t('.supplier_number') }

    = f.govuk_submit t(".submit.#{action_name}")

Use default url for form
Use default url for form

The url `provider_management_provider_external_user_path(@provider, @external_user)`
that is given for the form is specifically for an update on an existing
external user but this form needs to apply to creation of new users.

`form_with model: [:provider_management, @provider, @external_user]` without a
`url` parameter correctly sets a default url based on the namespace
(`provider_management`) and models (`@provider` and `@external_user`) provided
and this handles a new or existing `@external_user`.
