Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SFT-1074]: Hidden Group Field refactor to use db tables #1248

Merged
merged 5 commits into from May 1, 2024

Conversation

thejahid
Copy link
Contributor

@thejahid thejahid commented Apr 30, 2024

Related Ticket Number

SFT-1074

Description

Hidden Field Type group was saving data to the Freeform Settings model, and this caused issues for people using allowAdminChanges => false, who then were not able to persist the changes for field groups.

  • refactoring hidden field type groups to use the database table instead

)}
</GroupWrapper>
))}
{data.groups.grouped?.map(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not have changed the front-end at all, all of this logic needs to be in the backend.
You previously returned hidden and groups in the response, this can still remain exactly like that, just pick the hidden fields out of the array in the backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course

Comment on lines 27 to 32
if (!empty($hiddenTypes)) {
$groupRecord = new FieldTypeGroupRecord();
$groupRecord->uid = 'hidden';
$groupRecord->types = json_encode($hiddenTypes);
$groupRecord->save();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what if I have hidden groups set up already? Would this not trigger an error, saying that a record like this already exists?

Also I think using uid is not very safe, something might rely on all db rows using UUID v4.

How about using a record with handle freeform_hidden?
And before addinga new one, try to fetch one from the db by FieldTypeGroupRecord::findOne(['handle' => 'freeform_hidden']);

@thejahid thejahid changed the title fix group hidden problems fix(SFT-1074): group hidden problems May 1, 2024
@gustavs-gutmanis gustavs-gutmanis changed the title fix(SFT-1074): group hidden problems [SFT-1074]: Hidden Group Field refactor to use db tables May 1, 2024
@kjmartens kjmartens self-requested a review May 1, 2024 16:58
@kjmartens kjmartens merged commit 1bcfbb7 into v5 May 1, 2024
4 checks passed
@kjmartens kjmartens deleted the fix/v5/SFT-1074 branch May 1, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants