- Issue created by @keiserjb
- πΊπΈUnited States keiserjb
This version of the form works for me.
public function extraAdvancedFormFields(ContentEntityInterface $entity, FieldDefinitionInterface $fieldDefinition, FormStateInterface $formState, array $defaultValues = []) { $form = parent::extraAdvancedFormFields($entity, $fieldDefinition, $formState, $defaultValues); $settings = $fieldDefinition->getConfig($entity->bundle())->getSettings(); $form['automator_clean_up'] = [ '#type' => 'select', '#title' => $this->t('Text Manipulation'), '#description' => $this->t('These are possible text manipulations to run on each created tag.'), '#options' => [ '' => $this->t('None'), 'lowercase' => $this->t('lowercase'), 'uppercase' => $this->t('UPPERCASE'), 'first_char' => $this->t('First character uppercase'), ], // Use the default value from the third-party settings or fallback to a default. '#default_value' => $fieldDefinition->getConfig($entity->bundle()) ->getThirdPartySetting('ai_automators', 'automator_clean_up', 'first_char'), // Ensure fallback here '#weight' => 23, ]; $form['automator_clean_up'] = [ '#type' => 'select', '#title' => $this->t('Text Manipulation'), '#description' => $this->t('These are possible text manipulations to run on each created tag.'), '#options' => [ '' => $this->t('None'), 'lowercase' => $this->t('lowercase'), 'uppercase' => $this->t('UPPERCASE'), 'first_char' => $this->t('First character uppercase'), ], // Use the default value from the third-party settings or fallback to a default. '#default_value' => $fieldDefinition->getConfig($entity->bundle()) ->getThirdPartySetting('ai_automators', 'automator_clean_up', 'first_char'), // Ensure fallback here '#weight' => 23, ]; if ($settings['handler_settings']['auto_create']) { $form['automator_search_similar_tags'] = [ '#type' => 'checkbox', '#title' => 'Find similar tags', '#description' => $this->t('This will use GPT-4 to find similar tags. Meaning if the tag "Jesus Christ" exists and the system wants to store "Jesus" it will store it as "Jesus Christ". This uses extra calls and is slower and more costly.'), '#default_value' => $fieldDefinition->getConfig($entity->bundle()) ->getThirdPartySetting('ai_automators', 'automator_search_similar_tags', 1), // Ensure fallback here '#weight' => 23, ]; } return $form; }
- π©πͺGermany marcus_johansson
Thank you @keiserjb! Actually that wont work either, we moved from thirdpartysettings to configuration entities, so the way would be to look in the $defaultValues array.
If you want to add a MR, feel free to do so. If not I'll try to fix it during the weekend. I'll credit you anyway for finding the bug. If you do add a MR, look at the pipeline to make sure it passes all the tests.
-
marcus_johansson β
committed 0732f8a5 on 1.0.x
Issue #3478551 by marcus_johansson: Defaults for extraAdvancedFormFields...
-
marcus_johansson β
committed 0732f8a5 on 1.0.x
- π©πͺGermany marcus_johansson
I fixed this, it merged and can be tested on the dev branch.
- πΊπΈUnited States keiserjb
Thank you, I didn't turn on my work computer over the weekend.
-
marcus_johansson β
committed 0732f8a5 on 3479106-add-generic-interface
Issue #3478551 by marcus_johansson: Defaults for extraAdvancedFormFields...
-
marcus_johansson β
committed 0732f8a5 on 3479106-add-generic-interface
Automatically closed - issue fixed for 2 weeks with no activity.