diff options
author | Martin Wright <martin@mynameismartin.com> | 2017-07-07 09:38:11 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-07-07 11:43:33 +0100 |
commit | 6bd4d17176045ccaa211f99265f06466e1b4aece (patch) | |
tree | 4b68990978f4d8dbbeabb8f1b6142433833a8275 | |
parent | 6a0f8086f44dfe0d2d12b0a97a491f8c6ebe3ca2 (diff) |
Add an optional phone field to the contact form.
-rw-r--r-- | t/app/controller/contact.t | 2 | ||||
-rw-r--r-- | templates/web/base/contact/index.html | 6 | ||||
-rw-r--r-- | web/cobrands/sass/_base.scss | 15 |
3 files changed, 22 insertions, 1 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index d98d81868..0e87eb4cc 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -210,6 +210,7 @@ for my $test ( # we santise this when we submit so need to remove it delete $test->{fields}->{id} if $test->{fields}->{id} and $test->{fields}->{id} eq 'invalid'; + $test->{fields}->{'extra.phone'} = ''; is_deeply $mech->visible_form_values, $test->{fields}, 'form values'; }; } @@ -323,6 +324,7 @@ for my $test ( # we santise this when we submit so need to remove it delete $test->{fields}->{id} if $test->{fields}->{id} and $test->{fields}->{id} eq 'invalid'; + $test->{fields}->{'extra.phone'} = ''; is_deeply $mech->visible_form_values, $test->{fields}, 'form values'; if ( $test->{fields}->{dest} and $test->{fields}->{dest} eq 'update' ) { diff --git a/templates/web/base/contact/index.html b/templates/web/base/contact/index.html index f24f8afea..c79091668 100644 --- a/templates/web/base/contact/index.html +++ b/templates/web/base/contact/index.html @@ -77,13 +77,17 @@ [% END %] <input type="text" class="form-control required" name="name" id="form_name" value="[% form_name | html %]" size="30"> - <label for="form_email">[% loc('Your email') %]</label> [% IF field_errors.em %] <div class="form-error">[% field_errors.em %]</div> [% END %] <input type="text" class="form-control required email" name="em" id="form_email" value="[% em | html %]" size="30"> + <div class="form-group"> + <label for="form_phone">[% loc('Your phone number') %]</label> + <span class="required-text required-text--optional">optional</span> + <input type="text" class="form-control extra.phone" name="extra.phone" id="form_phone" value="" size="30"> + </div> <label for="form_subject">[% loc('Subject') %]</label> [% IF field_errors.subject %] diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index 5866ab986..8863487ba 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -294,6 +294,21 @@ select.form-control { } } +.form-group { + position: relative; + max-width: 27em; +} + +.required-text { + position: absolute; + right: 0; + top: 0; +} + +.required-text--optional { + color: #666; +} + .form-section-heading { font-family: inherit; color: inherit; |