Example for a CSHS-enabled term reference field on a custom form?

Created on 18 May 2023, about 1 year ago
Updated 22 May 2023, about 1 year ago

Thank you for providing an example of CSHS in a custom form. To take that further though, is there a way to apply CSHS to a term reference field in a custom form?

πŸ’¬ Support request
Status

Active

Version

4.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States dmudie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dmudie
  • πŸ‡ΊπŸ‡ΈUnited States dmudie

    I ended up generating options like this but please comment if there is a better way. Thanks.

    $term_options = [];
    $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree('vid-name',0,NULL,TRUE);
    foreach ($terms as $term) {
    	$termId = $term->id();
    	if($term->parent->target_id) {
    		$term_options[$termId] = new CshsOption($term->getName(),$term->parent->target_id);
    	} else {
    		$term_options[$termId] = new CshsOption($term->getName());
    	}
    }
    
Production build 0.69.0 2024