- Issue created by @k.prozorov
- last update
11 months ago Patch Failed to Apply - Status changed to Needs review
11 months ago 10:12am 13 February 2024 - last update
11 months ago Composer require-dev failure - Status changed to Needs work
11 months ago 12:22pm 13 February 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
Thanks a lot @k.prozorov for your contribution, this is really much appreciated.
I can see how token support for the language code can be helpful. Just wondering about the user interface because there the field is usually a drop-down and that doesn't allow the use of tokens. Any ideas on how to bring that together?
Then, a couple of housekeeping items:
- Feature requests and bug reports go into the latest dev release, that's why I've changed that status field accordingly
- Code contributions are only made through issue forks and merge requests, so if this issue moves forward, please remove tha patch and provide an MR instead
- Merge request !402Allow tokens in "Entity: create new" for langcode → (Closed) created by k.prozorov
- last update
10 months ago Composer require-dev failure - 🇷🇺Russia k.prozorov
At the moment, the langcode config is textarea in buildConfigurationForm (modules/content/src/Plugin/Action/NewEntity.php)
$form['langcode'] = [ '#type' => 'textfield', '#title' => $this->t('Language code'), '#default_value' => $this->configuration['langcode'], '#description' => $this->t('The language code of the new entity.'), '#weight' => -40, ];
And it will be convenient if you can use tokens there.
I have prepared a merge request based on my patch.Best regards.
- Status changed to Needs review
10 months ago 7:19pm 13 February 2024 - Status changed to Needs work
10 months ago 9:08am 14 February 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
Thanks for following up on this. The MR is currently failing tests, which is because
$this->tokenServices
is no longer plural in ECA 2 and needs to be called$this->tokenService
.However, the fact that the language code field is not a select field (drop-down) seems to be an oversight and should be fixed. I've just checked, we do have language code field in 3 different places:
- \Drupal\eca_base\Plugin\Action\Translate::buildConfigurationForm
- \Drupal\eca_content\Plugin\Action\NewEntity::buildConfigurationForm
- \Drupal\eca_content\Service\EntityLoader::buildConfigurationForm
Only in the "New Entity" action plugin it's a text field, the others use select fields as expected. So we should unify the behaviour there and make is a select field everywhere.
To still be able to provide token support, we could add an item to the select list which says
Defined by token
and that expects a pre-defined token name, e.g.eca_langcode
. Then, in all 3 plugins we can add the token replacement if the option for the token is being used, and users can use that by defining the language code in that token before calling one of these actions. - 🇷🇺Russia k.prozorov
k.prozorov → changed the visibility of the branch 3421088-allow-tokens-in to hidden.
- last update
10 months ago 297 pass - 🇷🇺Russia k.prozorov
I have prepared a new merge request for the 2.0.x version of the module.
In action NewEntity made the language selection as select field (drop-down)
Also, in 3 places (Translate, NewEntity, EntityLoader), I added the option to select the "Defined by token" option, when selected, the language code will be obtained from the tokeneca_langcode
.
I tested all changes on a clean install of drupal 10.2.3 and they work as expected. - Status changed to Needs review
10 months ago 7:00pm 17 February 2024 - Status changed to Needs work
10 months ago 2:36pm 21 February 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
This is very nice, thank you so much @k.prozorov
I've left a comment in the MR about error handling and fallback value. In addition, I wonder if we may shift the logic of those
langcode
fields into a trait so that we can avoid redundant code?There is now also the issue ✨ Add "Use token" option to drop-down lists Active where we may come up with a more generic approach to token support in select fields. Should we generalize this, or should that be addressed separately?
- 🇩🇪Germany jurgenhaas Gottmadingen
I've rebased the MR so that tests are passing again.
- 🇩🇪Germany jurgenhaas Gottmadingen
@k.prozorov any chance we can move this forward? I'd love to get this included in the forthcoming beta release for ECA 2.0
-
jurgenhaas →
committed 43e216fd on 2.0.x
Issue #3421088 by k.prozorov, jurgenhaas: Allow tokens in "Entity:...
-
jurgenhaas →
committed 43e216fd on 2.0.x
- 🇩🇪Germany jurgenhaas Gottmadingen
This is now implemented in a generic way:
- The form element, which has an
#option
element, can now also have an item'#eca_token_select_option' => TRUE,
. ECA will then automatically add an extra option to the drop down. - To receive the value, if this magic option is being selected, just call
$this->getTokenValue()
with the field key from the config form and a default value. This method is available by using\Drupal\eca\Plugin\ECA\PluginFormTrait
This way, a configuration form can even have multiple drop downs, each of which supporting the value being defined by a token.
- The form element, which has an
- Status changed to Fixed
8 months ago 12:33pm 3 May 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
Thanks a lot @k.prozorov for your contribution, the final implementation took on a lot from your issue fork and you have also been credited for this work. Thanks again and looking forward to your next one.
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Needs work
7 months ago 3:42pm 22 May 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
Re-opening this since we forgot 2 plugins that also support langcodes:
\Drupal\eca_access\Plugin\ECA\Event\AccessEvent
and\Drupal\eca_language\Plugin\Action\SetCurrentLangcode
-
jurgenhaas →
committed f0f9581e on 2.0.x
Issue #3421088 by k.prozorov, jurgenhaas: Allow tokens in "Entity:...
-
jurgenhaas →
committed f0f9581e on 2.0.x
- Status changed to Fixed
7 months ago 3:54pm 22 May 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
Updated the langcode handling in those 2 plugins as well.
-
jurgenhaas →
committed 98889475 on 2.0.x
Issue #3421088 by k.prozorov, jurgenhaas: Allow tokens in "Entity:...
-
jurgenhaas →
committed 98889475 on 2.0.x
-
jurgenhaas →
committed 1e2c5fb1 on 2.0.x
Issue #3421088 by k.prozorov, jurgenhaas: Allow tokens in "Entity:...
-
jurgenhaas →
committed 1e2c5fb1 on 2.0.x
- 🇩🇪Germany jurgenhaas Gottmadingen
Reverted the change for
\Drupal\eca_access\Plugin\ECA\Event\AccessEvent
since token support doesn't make sense for an event. There are no tokens available at that stage. Automatically closed - issue fixed for 2 weeks with no activity.