From e13b9cc047c60328d9c1458205ead4dfed34cb20 Mon Sep 17 00:00:00 2001 From: Herb Miller Date: Mon, 12 Sep 2022 10:57:13 +0100 Subject: [PATCH] bw_contact_form - Revert to the table form when content isn't set #207 --- shortcodes/oik-contact-form.php | 2 +- src/oik-contact-form/index.js | 7 +-- .../bb_BB/test_bw_contact_form_bb_BB.html | 44 ++++++++------- tests/data/en_GB/test_bw_contact_form.html | 54 +++++++++++-------- 4 files changed, 63 insertions(+), 44 deletions(-) diff --git a/shortcodes/oik-contact-form.php b/shortcodes/oik-contact-form.php index c576540..d5c96a2 100644 --- a/shortcodes/oik-contact-form.php +++ b/shortcodes/oik-contact-form.php @@ -83,7 +83,7 @@ function _bw_show_contact_form_oik( $atts, $user=null, $content=null ) { sdiv( $class ); bw_form(); if ( function_exists( 'bw_is_table')) { - bw_table_or_grid_start( false ); // Start a grid + bw_table_or_grid_start( empty($content) ); // Start a grid if fields are defined } else { stag( 'table' ); } diff --git a/src/oik-contact-form/index.js b/src/oik-contact-form/index.js index dfe9c2d..f94bd74 100644 --- a/src/oik-contact-form/index.js +++ b/src/oik-contact-form/index.js @@ -46,9 +46,10 @@ registerBlockType( } ), } ); - const innerBlocksTemplate = [ ['oik/contact-field', { label: 'Name', type: 'text', 'required': true }], - ['oik/contact-field', { label: 'Email', type: 'email', 'required': true }], - ['oik/contact-field', { label: 'Message', type:'textarea', 'required': true }] + const innerBlocksTemplate = [ ['oik/contact-field', { label: 'Name', type: 'text', 'required': true, 'requiredIndicator': ' *' }], + ['oik/contact-field', { label: 'Email', type: 'email', 'required': true, 'requiredIndicator': ' *' }], + ['oik/contact-field', { label: 'Subject', type: 'text', 'required': false }], + ['oik/contact-field', { label: 'Message', type:'textarea', 'required': true, 'requiredIndicator': ' *' }] ]; const onChangeContact = (event) => { props.setAttributes({contact: event}); diff --git a/tests/data/bb_BB/test_bw_contact_form_bb_BB.html b/tests/data/bb_BB/test_bw_contact_form_bb_BB.html index 6e4537e..325baea 100644 --- a/tests/data/bb_BB/test_bw_contact_form_bb_BB.html +++ b/tests/data/bb_BB/test_bw_contact_form_bb_BB.html @@ -1,32 +1,40 @@
-
-
+ + + + + + + + + + + + + + + + + +
- -
+
- -
+
- -
+
- -
+
- -
+
- -
+
- -
+
- - +
diff --git a/tests/data/en_GB/test_bw_contact_form.html b/tests/data/en_GB/test_bw_contact_form.html index cc0fd4c..36ba88a 100644 --- a/tests/data/en_GB/test_bw_contact_form.html +++ b/tests/data/en_GB/test_bw_contact_form.html @@ -1,41 +1,51 @@
-
-
+ + + + + + + + + + + + + + + + + +
- -
+
- -
+
- -
+
- -
+
- -
+
- -
+
- -
+
- - +
-
+ + -
-
+ + -
+ +