- Issue created by @Josh Waihi
- 🇬🇧United Kingdom MrDaleSmith
The tests are failing because you are using Drupal::service() inside an object: you need to be using dependency injection to get the Ai provider service in there. See https://drupal.stackexchange.com/questions/224247/how-do-i-inject-a-depe... for a steer if you don't know how to do it.
- First commit to issue fork.
- 🇬🇧United Kingdom MrDaleSmith
Tests still failing: https://git.drupalcode.org/issue/ai-3515209/-/jobs/4833128 - the $provider_id variable only exists if the $item is not empty, so it is theoretically possible that you then try to put a non-existent variable in the $form_state. The easiest fix is to give the $provider_id a NULL value outside of your if statement.
- 🇬🇧United Kingdom MrDaleSmith
Applies fine and does what it says it will.
The default value functionality however requires you to set up a default when adding the field type to a node type, which isn't the behaviour of others field: default values are usually optional when setting up a content type, with a "Set default value" checkbox. I think users will expect it to work this way, given it is the standard for Drupal field types.
Possibly the field type should just be an additional item in the Reference category rathewr than its own thing when adding a new field - it doesn't do anything different to the other reference field types - but that may be a personal preference.
- 🇮🇳India anjaliprasannan
@mrdalesmith
The current implementation removes the standalone field type and introduces an aiprovider entity, which is referenced using an entity reference field type. Additionally, the default value can now be set through the field widget.There are still some issues with the implementation, but before proceeding further, I wanted to confirm if this is the kind of setup you were expecting for the AI Provider entity reference.
- 🇬🇧United Kingdom MrDaleSmith
No, not really: why does it require an entity to be created? I was just suggesting changing the label so the reference widget you'd created appears in the "reference" list when setting up a new field, rather than as a separate field type.
Also, I'm not a maintainer on this project so I wouldn't completely retool your approach based on my suggestions without any feedback from the actual maintainers. My suggestions have no weight here.