- Issue created by @Gábor Hojtsy
AFAICT, entity builders are only invoked on a request with form input, not on the initial form build. Populating the field on the initial build probably needs the #default_value to be set or similar?
- 🇭🇺Hungary Gábor Hojtsy Hungary
@godotislate: I don't believe that is a problem, we are testing whether on form submission the entity gets the language, and it appears it does not (likely the third party setting is not saved).
@gábor hojtsy: I see now that the entity_builder is supposed to populate the third party setting on the add form, before going to the edit form in the test.
The issue about the edit form field not being populated correctly isn't an issue with the entity builder not being invoked, it's with this logic in
PluralFormulaLanguageFormBase::form()
:// Pick previous plural formula if editing an existing language. $plural_formula = ''; if (isset($form['langcode']['#value'])) { $editingLangcode = $form['langcode']['#value']; /** @var \Drupal\language\ConfigurableLanguageInterface $language */ $language = $form_state->getFormObject()->getEntity(); $plural_formula = $language->getThirdPartySetting('l10n_pconfig', 'formula'); }
In
Drupal\language\Form\LanguageFormBase::commonForm()
, this is how the form is built:if ($language->getId()) { $form['langcode_view'] = [ '#type' => 'item', '#title' => $this->t('Language code'), '#markup' => $language->id(), ]; } else { $form['langcode'] = [ '#type' => 'textfield', '#title' => $this->t('Language code'), '#maxlength' => 12, '#required' => TRUE, '#default_value' => '', '#disabled' => FALSE, '#description' => $this->t('Use language codes as <a href=":w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', [':w3ctags' => 'https://www.w3.org/International/articles/language-tags/']), ]; }
So
isset($form['langcode']['#value'])
inPluralFormulaLanguageFormBase::form()
is FALSE, and the third party settings are not loaded to populate the form value.-
gábor hojtsy →
committed 8f10fae7 on 2.0.x
Issue #3533953 by gábor hojtsy, godotislate: Entity builder method is...
-
gábor hojtsy →
committed 8f10fae7 on 2.0.x