JavaScript for WordPress Forums Gutenberg Development Integer attributes are not getting saved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #75610
    crerem
    Participant

    I’m doing my first blocks and i notices that attributes declared as integer are not getting saved . I’m using them for dynamic blocks and their value can be retrieved when you add the block for the first time but not on page reload. I used console.log to track them and i got an undefined on page reload.

    If i change the type to string everything works as expected. Any idea why integer is not working ?

    This is my code

     attributes:{
                propertyid:{
                    type:'integer',
                    select:'p'
                },
            },
    
     <form>
                        <label className="wpresidence_editor_label">Property ID: {propertyid}</label>
                         {   isSelected && (
                              <PlainText 
                                tagname="h2"
                                value={ propertyid }
                                onChange={ onChangeNotesContent }
                            />)
                        }  
                    </form>
    
       function onChangeNotesContent (newContent) {
                setAttributes( { propertyid: newContent } );
            }
    #75713
    Zac Gordon
    Keymaster

    Does “number” work for you?

    Attribute types are not exactly 1 to 1 mapping of native JavaScript types

    #75853
    crerem
    Participant

    Hi Zac,
    Yes, “number” works.
    Thank you

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.