Skip to content

Commit

Permalink
Allow override of the email address #207
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Sep 13, 2022
1 parent 7c1c1cd commit c647a00
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/oik-contact-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,29 @@ registerBlockType(
const onChangeContact = (event) => {
props.setAttributes({contact: event});
};
const onChangeEmail = (event) => {
props.setAttributes({email: event});

};
/**
* Reset fields to defaults if they're blanked out by the user.
*/
const { email, contact } = attributes;
if ( email=== undefined || email.trim() === '') {
const attributeSettings = wp.data.select('core/blocks').getBlockType('oik/contact-form').attributes;
props.setAttributes({email: attributeSettings.email.default});
}
if ( contact===undefined || contact.trim() === '' ) {
const attributeSettings = wp.data.select('core/blocks').getBlockType('oik/contact-form').attributes;
props.setAttributes({contact: attributeSettings.contact.default});
}
return (
<Fragment>
<InspectorControls>
<PanelBody>
<PanelRow>
<TextControl label={__("Email address", "oik" )} value={attributes.email} onChange={onChangeEmail}/>
</PanelRow>
<PanelRow>
<TextControl label={__("Text for Submit button", "oik" )} value={attributes.contact} onChange={onChangeContact}/>
</PanelRow>
Expand Down

0 comments on commit c647a00

Please sign in to comment.