<% content_for :title, @signup.page_title %>

<header class="signups">
  <% if @signup.beta? %>
    <%= render partial: 'govuk_component/beta_label' %>
  <% end %>
  <h1>
    <span class="aside">Email alert subscription</span>
    <%= @signup.name %>
  </h1>
</header>

<div class="outer-block">
  <div class="inner-block signup-content">
    <%= form_tag email_alert_subscriptions_path, class: 'signup-choices form' do %>
      <% if @signup.choices? %>
        <fieldset>
          <legend>
            Select the email alerts you need
          </legend>
          <% @signup.choices.each do |choice| %>
            <%= label_tag "choices[#{@signup.choice_key}][#{choice.key}]", class: 'block-label' do %>
              <%= check_box_tag "choices[#{@signup.choice_key}][#{choice.key}]", 1, true, class: 'checkbox' %>
              <%= choice.name %>
            <% end %>
          <% end %>
        </fieldset>
      <% end %>

      <p><%= @signup.body %></p>
      <%= submit_tag 'Create subscription', class: "button" %>
    <% end %>

  </div>
</div>

<% content_for :title, @signup.page_title %>

<header class="signups">
  <% if @signup.beta? %>
    <%= render partial: 'govuk_component/beta_label' %>
  <% end %>
  <h1>
    <span class="aside">Email alert subscription</span>
    <%= @signup.name %>
  </h1>
</header>

<div class="outer-block">
  <div class="inner-block signup-content">
    <%= form_tag email_alert_subscriptions_path, class: 'signup-choices form' do %>
      <% if @signup.choices? %>
        <fieldset>
          <legend>
            Select the email alerts you need
          </legend>
          <% @signup.choices.each do |choice| %>
            <%= label_tag "choices[#{@signup.choice_key}][#{choice.key}]", class: 'block-label' do %>
              <%= check_box_tag "choices[#{@signup.choice_key}][#{choice.key}]", 1, choice.prechecked, class: 'checkbox' %>
              <%= choice.name %>
            <% end %>
          <% end %>
        </fieldset>
      <% end %>

      <p><%= @signup.body %></p>
      <%= submit_tag 'Create subscription', class: "button" %>
    <% end %>

  </div>
</div>

Use default prechecked state on page load
Use default prechecked state on page load

Rather than always prechecking select boxes, use the prechecked state
from the metadata about an email signup currently pulled from finder-api.
