Skip to content

Commit

Permalink
bw_contact_form - Revert to the table form when content isn't set #207
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Sep 12, 2022
1 parent 518cd5f commit e13b9cc
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 44 deletions.
2 changes: 1 addition & 1 deletion shortcodes/oik-contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
Expand Down
7 changes: 4 additions & 3 deletions src/oik-contact-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
44 changes: 26 additions & 18 deletions tests/data/bb_BB/test_bw_contact_form_bb_BB.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
<div class="bw_contact_form">
<form method="post">
<div class="bw_grid">
<div>
<table>
<tr>
<td>
<label for="oiku_contact-1_name">Nmae *</label>
</div>
<div>
</td>
<td>
<input type="text" size="30" name="oiku_contact-1_name" id="oiku_contact-1_name" value="" class="textBox"required />
</div>
<div>
</td>
</tr>
<tr>
<td>
<label for="oiku_contact-1_email">Eamil *</label>
</div>
<div>
</td>
<td>
<input type="email" name="oiku_contact-1_email" size="30" class="textBox"required />
</div>
<div>
</td>
</tr>
<tr>
<td>
<label for="oiku_contact-1_subject">Sbuejct</label>
</div>
<div>
</td>
<td>
<input type="text" size="30" name="oiku_contact-1_subject" id="oiku_contact-1_subject" value="" class="textBox" />
</div>
<div>
</td>
</tr>
<tr>
<td>
<label for="oiku_contact-1_message">Mseasge</label>
</div>
<div>
</td>
<td>
<textarea rows="10" cols="30" name="oiku_contact-1_message">
</textarea>
</div>
</div>
</td>
</tr>
</table>
<input type="hidden" id="_oik_contact_nonce" name="_oik_contact_nonce" value="nonsense" />
<input type="hidden" name="oiku_email_to" value="herb@bobbingwide.com" />
<input type="submit" name="oiku_contact-1" value="Contact mE" />
Expand Down
54 changes: 32 additions & 22 deletions tests/data/en_GB/test_bw_contact_form.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
<div class="bw_contact_form">
<form method="post">
<div class="bw_grid">
<div>
<table>
<tr>
<td>
<label for="oiku_contact-1_name">Name *</label>
</div>
<div>
</td>
<td>
<input type="text" size="30" name="oiku_contact-1_name" id="oiku_contact-1_name" value="" class="textBox"required />
</div>
<div>
</td>
</tr>
<tr>
<td>
<label for="oiku_contact-1_email">Email *</label>
</div>
<div>
</td>
<td>
<input type="email" name="oiku_contact-1_email" size="30" class="textBox"required />
</div>
<div>
</td>
</tr>
<tr>
<td>
<label for="oiku_contact-1_subject">Subject</label>
</div>
<div>
</td>
<td>
<input type="text" size="30" name="oiku_contact-1_subject" id="oiku_contact-1_subject" value="" class="textBox" />
</div>
<div>
</td>
</tr>
<tr>
<td>
<label for="oiku_contact-1_message">Message</label>
</div>
<div>
</td>
<td>
<textarea rows="10" cols="30" name="oiku_contact-1_message">
</textarea>
</div>
</div>
</td>
</tr>
</table>
<input type="hidden" id="_oik_contact_nonce" name="_oik_contact_nonce" value="nonsense" />
<input type="hidden" name="oiku_email_to" value="herb@bobbingwide.com" />
<div style="display:none">
<div>
<tr>
<td>
<label for="oik_saccharin_bowl">Humans leave this blank</label>
</div>
<div>
</td>
<td>
<input type="text" size="10" name="oik_saccharin_bowl" id="oik_saccharin_bowl" value="" class="" />
</div>
</td>
</tr>
</div>
<input type="submit" name="oiku_contact-1" value="Contact me" />
</form>
Expand Down

0 comments on commit e13b9cc

Please sign in to comment.