diff --git a/src/oik-contact-form/index.js b/src/oik-contact-form/index.js index f94bd74..3cdf6e7 100644 --- a/src/oik-contact-form/index.js +++ b/src/oik-contact-form/index.js @@ -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 ( + + +