setFormClass('materio_block', '\Drupal\materio_simplenews\Form\MaterioSubscriptionsBlockForm'); } /** * Implements hook_form_alter(). */ // node_simplenews_issue_edit_form // function materio_simplenews_form_alter(&$form, &$form_state, $form_id) { function materio_simplenews_form_node_simplenews_issue_form_alter(&$form, &$form_state, $form_id) { if(isset($_REQUEST['newsletter'])){ $news_id = $_REQUEST['newsletter']; $newsletters = array_keys(simplenews_newsletter_get_all()); if(in_array($news_id, $newsletters)){ // prepopulate type of news $form['simplenews_issue']['widget']['target_id']['#default_value'] = [$news_id]; $form['simplenews_issue']['widget']['target_id']['#disabled'] = true; // change default template regarding type of news $form['body']['widget'][0]['#default_value'] = materio_simplenews_getSimplenewsNodeBodyTemplate($news_id); $form['body']['widget'][0]['#rows'] = 50; } } } function materio_simplenews_getSimplenewsNodeBodyTemplate($news_id){ return file_get_contents(drupal_get_path('module', 'materio_simplenews').'/templates/simplenews_'.$news_id.'_node.html'); }