I am looking to edit an existing block to add inspector controls that save as meta data. I have been beating my head trying to find how to save the data. The following code adds a text field to the inspector system . I can add the field but for some reason the field does not save. I can not for the life of me figure it out.

var el = wp.element.createElement,
    Fragment = wp.element.Fragment
    registerBlockType = wp.blocks.registerBlockType,
    RichText = wp.editor.RichText,
    BlockControls = wp.editor.BlockControls,
    AlignmentToolbar = wp.editor.AlignmentToolbar,
    Fields = wp.components;

var withInspectorControlsEdit = wp.compose.createHigherOrderComponent( function( BlockEdit ) {
    return function( props ) {
        return el(
            el( BlockEdit, props ),
                            label: 'Test Field',
                            value: props.attributes.testField,
                            onChange: function(e){
                                props.setAttributes({ testField: e });
}, 'withInspectorControlsEdit' );
wp.hooks.addFilter( 'editor.BlockEdit', 'acf/accordion', withInspectorControlsEdit );
  • This isn't off topic, but, you really should open an issue over on the gutenberg github, it's the best place to ask these kinds of questions in the run up to the 5.0 release ( I asked numerous gutenberg leads and they said so )
    – Tom J Nowell
    Oct 20, 2018 at 21:14

1 Answer 1


Have you set your attribute (testField) up as meta?

attributes: { testField: { type: 'string', source: 'meta', meta: 'testField' }, },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.