Created
July 6, 2016 01:31
-
-
Save cmcintosh/daab90a41db51175ac016400797494ec to your computer and use it in GitHub Desktop.
Customize Fieldsets in Drupal 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_theme, see https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_theme/8.2.x | |
*/ | |
function custom_fieldset_theme($existing, $type, $theme, $path) { | |
return array( | |
'my_fieldset' => array( | |
'template' => 'my_fieldset', | |
'path' => $path .'/templates', | |
'render element' => 'element' | |
) | |
); | |
} | |
/** | |
* This is the theme callback for the custom fieldset theme. | |
*/ | |
function theme_my_fieldset(&$variables) { | |
// See http://www.drupalcontrib.org/api/drupal/drupal!core!includes!form.inc/function/theme_fieldset/8 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* {@inheritdoc} | |
*/ | |
public function buildForm ($form, $formState) { | |
// First define our fieldset, and add a #theme tag to our element. | |
// See http://www.drupalcontrib.org/api/drupal/drupal!core!includes!form.inc/function/theme_fieldset/8 | |
// for the default implementation. | |
$form['customFieldset'] = array( | |
'#type' => 'fieldset', | |
'#theme' => 'my_fieldset', | |
'#title' => t('My Custom Fieldset') | |
); | |
return $form; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// insert your custom html. | |
// You must clear cache after each change. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment