I'm creating a custom module and would like to allow the site editor to create a block and select which roles have access to the block. I'm looking for ideas on how to add this input field (select from existing roles) into the block settings.

Would appreciate being pointed at some example code I can use. 

https://github.com/backdrop-contrib/conditional_content_block/issues/5

Comments

This seems to work for me.

$roles = user_roles();
$form['my_role'] = array(
  '#type' => 'select',
  '#title' => 'My Role',
  '#options' => $roles,
  '#default_value' => $settings['my_role'],
);