turnstile

Drupal paywall plugin
Log | Files | Refs | README | LICENSE

commit 60cffc9dcffb515d8f216ac8a92653f4c6bbccf0
parent ca2cbc3f4f037efc627bb4547fd70715d4683abf
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 11 Oct 2025 16:12:48 +0200

get price category drop-down to work

Diffstat:
Msrc/Form/TurnstileSettingsForm.php | 16++++++++++------
Mturnstile.routing.yml | 4++--
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/Form/TurnstileSettingsForm.php b/src/Form/TurnstileSettingsForm.php @@ -320,11 +320,11 @@ class TurnstileSettingsForm extends ConfigFormBase { $field_category_storage = FieldStorageConfig::create([ 'field_name' => 'field_turnstile_price_category', 'entity_type' => 'node', - 'type' => 'string', // FIXME: bad type! + 'type' => 'entity_reference', 'module' => 'core', // FIXME: should this be system? 'cardinality' => 1, 'settings' => [ - 'max_length' => 255, + 'target_type' => 'turnstile_price_category', ], ]); $field_category_storage->save(); @@ -405,12 +405,12 @@ class TurnstileSettingsForm extends ConfigFormBase { 'description' => t('Select a price category for this content.'), 'required' => FALSE, 'settings' => [ - 'handler' => 'default', + 'handler' => 'default:turnstile_price_category', 'handler_settings' => [ 'target_bundles' => NULL, 'sort' => [ 'field' => 'label', - 'direction' => 'asc', + 'direction' => 'ASC', ], 'auto_create' => FALSE, ], @@ -423,8 +423,9 @@ class TurnstileSettingsForm extends ConfigFormBase { $form_display = EntityFormDisplay::load('node.' . $bundle . '.default'); if ($form_display) { $form_display->setComponent('field_turnstile_price_category', [ - 'type' => 'string_textfield', // FIXME: wrong type! + 'type' => 'options_select', 'weight' => 10, + 'settings' => [], ]); $form_display->save(); } @@ -433,9 +434,12 @@ class TurnstileSettingsForm extends ConfigFormBase { $view_display = EntityViewDisplay::load('node.' . $bundle . '.default'); if ($view_display) { $view_display->setComponent('field_turnstile_price_category', [ - 'type' => 'entity_reference', + 'type' => 'entity_reference_label', 'weight' => 10, 'label' => 'above', + 'settings' => [ + 'link' => FALSE, + ], ]); $view_display->save(); } diff --git a/turnstile.routing.yml b/turnstile.routing.yml @@ -26,7 +26,7 @@ entity.turnstile_price_category.add_form: _permission: 'administer price categories' entity.turnstile_price_category.edit_form: - path: '/admin/structure/price-categories/{price_category}/edit' + path: '/admin/structure/price-categories/{turnstile_price_category}/edit' defaults: _entity_form: 'turnstile_price_category.edit' _title: 'Edit price category' @@ -34,7 +34,7 @@ entity.turnstile_price_category.edit_form: _permission: 'administer price categories' entity.turnstile_price_category.delete_form: - path: '/admin/structure/price-categories/{price_category}/delete' + path: '/admin/structure/price-categories/{turnstile_price_category}/delete' defaults: _entity_form: 'turnstile_price_category.delete' _title: 'Delete price category'