<% question_has_errors = resource.errors[question_id].any? %>
"> <% if legend.present? %>

<%= legend[:caption][:text] if legend[:caption].present? %> <%= legend[:text] %>

<% end %>
"> <%= hint %>
<% if question_has_errors %>

"> Error: <%= resource.errors[question_id].first %>

<% end %> <%= f.text_field question_id.to_sym, class: "govuk-input moj-js-datepicker-input#{' govuk-input--error' if question_has_errors}", id: [resource_type, question_id].join("_"), aria: { describedby: "#{[resource_type, question_id].join('_')}-hint#{"#{[resource_type, question_id].join('_')} -error" if question_has_errors}" }, autocomplete: "off", value: resource[question_id]&.strftime("%d/%m/%Y") %>