Open Boefjim opened 3 weeks ago
Hi @Boefjim,
Thank you for creating this issue. It's an interesting one.
Please confirm I have this right:
If the above is true, configuring 'Field' config on the Region Fieldtype will produce this issue within a replicator. I think in this situation you would have to use the Region in Country Fieldtype. Would this work for your use case?
Otherwise I'll be able to take a look at this next week.
I had a quick look at Region in Country Fieldtype to confirm. I believe it will work as expected in a replicator because it is not using the handle of the Country Fieldtype. It is its own isolated Fieldtype.
Please let me know whether it is suitable.
country
handle), since the handle should be unique by the rules of statamic, there is not really a "first".Using the Region in Country Fieldtype sadly is not a fitting alternative for my use case, because it should be possible to select a country without any region, but that fieldtype does not return any value when no region is selected.
Technically it would be possible to have both the Country Fieldtype field and a Region in Country fieldtype field and then select the same country again in the Region in Country Fieldtype field, but that is an extra step for the content editor that I hope would not be necessary.
I understand.
As I understand it the Replicator Fieldtype on save saves its entries essentially as an array. Which works because you define that structure with the blueprint.
On the frontend (the control panel), in the case of Region Fieldtype, it is referencing the Country Fieldtype by handle. It has a default handle, they should be unique, and handles are in the control of the user/blueprint. I don't believe it would be possible to define the relationship between each Country Fieldtype and Region Fieldtype within a Replicator.
However, I can probably add a feature to the Region in Country Fieldtype, or an entirely new Fieldtype, that makes selecting region optional.
I can probably look at this next week.
Hey @kadegray were you able to look at this yet?
Would love to have the new field (feature) available to use!
@Boefjim I've started looking at this now.
@Boefjim Just an update.
So the Region in Country Fieldtype within a replicator, on initial save, if you only select country and save, will have only the country (as ISO 3166-1; "US") saved to the entry.
However, there are two bugs:
So basically what is currently happening is when a region is selected in the Region in Country Fieldtype is that it gets stuck either saving the previously selected region (selected before clearing) or a currently selected region. But you can't go back to only country unless you select another country.
I'm going to focus on fixing these bugs, at the moment I have a few hours each day.
@Boefjim I've released changes in 1.2.6, please run composer update kadegray/statamic-country-and-region-fieldtypes
.
You will see now on the in the Region in Country fieldtype that there is a config called Region is required
. By default it is enabled, however if you disable it it will permit only country to be saved.
When using both the country & region fieldtypes within a replicator, the
country
field at the root of the blueprint is still used to determine the possible regions.Would it be possible to use the
country
field within the replicator instead?