bID not available until first block save

Permalink
I need to attach a new bID to my block before it gets saved, how can I do this?

ob7dev
 
Mainio replied on at Permalink Best Answer Reply
Mainio
After you have called parent::save() in the block controller, then bID is available.

I don't think it's possible to get before that.
JohntheFish replied on at Permalink Reply
JohntheFish
It doesn't exist before that. Save creates the bID through the database auto-incrementing the field since the previous (any) block save.
ob7dev replied on at Permalink Reply
ob7dev
To attach a unique identifier before the block is even saved, my solution involved generating a random string from the add() method and passing it to the block form, which then gets saved to the db.