.nested-fields.indent-fieldset.js-test-rep-order
  - @representation_order_count += 1
  %h3.bold-normal
    = t('.representation_order')

  %span.auto-width
    = f.anchored_label 'Representation order date', "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_representation_order_date"
    .form-hint.xsmall.zero-vert-margin
      &nbsp;
    = f.gov_uk_date_field :representation_order_date
    = validation_error_message(@error_presenter, "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_representation_order_date")

  %span.auto-width
    = f.anchored_label t('maat_reference_number'), "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_maat_reference"
    .form-hint.xsmall.zero-vert-margin
      = t("maat_reference_number_eg")
    = f.text_field :maat_reference
    = validation_error_message(@error_presenter, "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_maat_reference")

  = link_to_remove_association t('link.remove_rep_order'), f if @representation_order_count > 1

.nested-fields.indent-fieldset.js-test-rep-order
  - @representation_order_count += 1
  %h3.bold-normal
    = t('.representation_order')

  %span.auto-width
    = f.anchored_label 'Representation order date', "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_representation_order_date"
    .form-hint.xsmall.zero-vert-margin
      &nbsp;
    = f.gov_uk_date_field :representation_order_date
    = validation_error_message(@error_presenter, "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_representation_order_date")

  %span.auto-width
    = f.anchored_label t('maat_reference_number'), "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_maat_reference"
    .form-hint.xsmall.zero-vert-margin
      = t("maat_reference_number_eg")
    = f.text_field :maat_reference
    = validation_error_message(@error_presenter, "defendant_#{@defendant_count}_representation_order_#{@representation_order_count}_maat_reference")

  = link_to_remove_association t('link.remove_rep_order'), f

Fix a bug that related to rep order remove links
Fix a bug that related to rep order remove links

rep orders creation via cocoon for second defendants
were not receiving emove links. This was because of
the use of backend logic related to rep order counts
and them not being approrpriate for front-end conditional
logic if certain circumstances.

To implement this via javascript see:
http://stackoverflow.com/questions/12934925/cocoon-add-association-how-to-limit-number-of-associations
