Skip to content

Commit

Permalink
Merge pull request #393 from NHSLeadership/DI-2985-gravity-forms-conf…
Browse files Browse the repository at this point in the history
…irmation

added all_fields template to fix bug with submission being blocked
  • Loading branch information
tblacker7 authored Feb 22, 2021
2 parents 13acf6a + b4e2cb7 commit e045153
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 195 deletions.
56 changes: 56 additions & 0 deletions assets/scss/gravity-forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,59 @@
color : $color_nhsuk-black;
padding : nhsuk-spacing(1);
}

.gf-all-fields { // style up the all-fields summary to look like it should.
@extend .nhsuk-summary-list;
li {
&.field-type-section {
background-color: $color_nhsuk-white;
text-align: center;

span:empty {
padding-bottom: 0;
padding-top: 0;
}
}
@extend .nhsuk-summary-list__row;
span:not(.label) {
@extend .nhsuk-summary-list__value;
}
span.label {
@extend .nhsuk-summary-list__key;
}
hr.gpnf-nested-entries-hr {
display: none;
}
table[bgcolor="#EAEAEA"] { // nested forms display.
background: inherit;
border-top: none !important; // !important required to over ride plugin genertaed inline styling.
table[bgcolor="#FFFFFF"] { // nested forms display.

tr[bgcolor="#FAF4EA"] { // sub form headers. Get rid of nasty orange/tan appearance.
background : $color_nhsuk-grey-5;
color : $color_nhsuk-blue;
td {
padding-top: nhsuk-spacing(1);
padding-bottom: nhsuk-spacing(1);
font {
font-size: $nhsuk-base-font-size !important // !important required to over ride plugin genertaed inline styling.
}
}
}
tr[bgcolor="#FFFFFF"] {
background : $color_nhsuk-grey-5 !important;
}
td:empty {
display: none;
}
}
}
table.gfcs-value { // chained select displays.
td {
span {
border-bottom : none;
}
}
}
}
}
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @link https://developer.wordpress.org/themes/basics/theme-functions/
* @package Nightingale
* @copyright NHS Leadership Academy, Tony Blacker
* @version 2.3.1.2 9th February 2020
* @version 2.3.1.3 22nd February 2021
*/

/**
Expand Down
55 changes: 55 additions & 0 deletions gravity-forms/all-fields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Customised Gravity Forms summary markup
*
* @date February 22nd 2021
* @version 1.0
* @author Tony Blacker
* @organisation NHS Leadership Academy
* @copyright OGL v3
* @package Nightingale Theme
* Most email clients do not support style blocks. We'll define our styles here and output them inline in the markup below.
*/

$styles = array(
'span.label' => 'vertical-align: top; font-weight: bold;',
);

// Make a back-up of the styles we've just defined. This allows us to make temporary changes to the styles below and then
// reset the styles for the next item.
$reset_styles = $styles;
?>

<ul class="gf-all-fields"">
<?php
foreach ( $items as $item ) :

// Get field object for use in template.
$field = isset( $item['field'] ) ? $item['field'] : new GF_Field();

// Don't show pricing fields (just like GF default {all_fields}).
if ( GFCommon::is_pricing_field( $field ) ) {
continue;
}

// Change the style a bit for Section fields.
if ( $field->get_input_type() === 'section' ) {
$styles['li'] .= 'padding-bottom: 10px;';
}

// Add the field type as a CSS class for every field to make styling specific elements easier.
$css_class = isset( $field ) ? 'field-type-' . $field->type : '';

?>

<li class="<?php echo esc_attr( $css_class ); ?>"">
<span class="label" style="<?php echo esc_attr( $styles['span.label'] ); ?>"><?php echo esc_html( $item['label'] ); ?></span>
<span><?php echo $item['value']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
</li>

<?php
// Reset any temporary changes we made to our core styles.
$styles = $reset_styles;
endforeach;
?>
</ul>
14 changes: 0 additions & 14 deletions inc/gravity-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,6 @@ function nightingale_clean_gf_inputs( $field_content, $field ) {
$field_content = str_replace( 'gfield_consent_label', 'gfield_consent_label nhsuk-label nhsuk-checkboxes__label', $field_content );
$field_content = str_replace( "type='checkbox'", "type='checkbox' class='nhsuk-checkboxes__input'", $field_content );
$field_content = '<div class="nhsuk_checkboxes">' . $field_content . '</div>';
break;
case 'html':
// style the submission preview screen.
$field_content = preg_replace( '/<table(.*?)>(.*?)<\/table>/si', '<div>$2</div>', $field_content );
$field_content = preg_replace( '/<table(.*?)>(.*?)<\/table>/si', '<div><dl class="nhsuk-summary-list">$2</dl></div>', $field_content );
$field_content = preg_replace( '/<tbody>(.*?)<\/tbody>/i', '$1', $field_content );
$field_content = preg_replace( '/<tr bgcolor="\#EAF2FA"(.*?)<\/tr>/si', '<div class="nhsuk-summary-list__row"><dt class="nhsuk-summary-list__key"$1</dt>', $field_content );
$field_content = preg_replace( '/<tr bgcolor="\#FFFFFF"(.*?)<\/tr>/si', '<dd class="nhsuk-summary-list__value"$1</dd></div>', $field_content );
$field_content = preg_replace( '/<td width="20">&nbsp;<\/td>/si', '', $field_content );


$field_content = preg_replace( '/<td(.*?)>(.*?)<\/td>/si', '$2', $field_content );
$field_content = preg_replace( '/<font style="font-family: sans-serif; font-size:12px;">(.*?)<\/font>/si', '$1', $field_content );

break;
default: // everything else.
$field_content = $field_content;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "git",
"url": "https://github.com/NHSLeadership/nightingale-2-0.git"
},
"version": "2.2.4",
"version": "2.3.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Requires PHP: 5.6
License: GPL v3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Theme URI: https://digital.leadershipacademy.nhs.uk/digital-capabilities/websites/nightingale-theme-user-guide/
Version: 2.3.1
Stable tag: 2.3.1
Version: 2.3.1.3
Stable tag: 2.3.1.3


== Description ==
Expand Down Expand Up @@ -43,6 +43,11 @@ one level only. To show further levels, we recommend using the right (or left) h

== Changelog

= 2.3.1.3 =
* bugfix release:
* minor change to gravity forms summary (all_fields) view to prevent markup error that blocked submission.


= 2.3.1.2 =
* bugfix release:
* removed various warnings triggered by unchecked values
Expand Down
Loading

0 comments on commit e045153

Please sign in to comment.