My use case:
I would like to create a unique textfield per region in a custom form.
MYMODULE/MYMODULE.module:
function MYMODULE_preprocess_region(&$variables) {
foreach (array($variables['elements']['#region']) as $key) {
drupal_set_message($key);
}
}
MYMODULE/src/form/MyModuleForm.php:
protected function getEditableConfigNames() {
return [
'module_config.module_config_settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('module_config.module_config_settings');
//build this...
$form['region_name'] = array(
'#type' => 'textfield',
'#title' => t('Form Item Title),
);
return parent::buildForm($form, $form_state);
}
What is the appropriate way to pass variables/info from the .module file to the .form?
*Note: I have a fully functioning form, hopefully I am showing enough of it to illustrate my focus.