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

Data error in a field of the nested form type when creating a model. #5759

Closed
Dok2314 opened this issue Oct 13, 2023 · 4 comments
Closed

Data error in a field of the nested form type when creating a model. #5759

Dok2314 opened this issue Oct 13, 2023 · 4 comments

Comments

@Dok2314
Copy link

Dok2314 commented Oct 13, 2023

Example of my form.yaml:

fields:
primary:
label: Primary
span: auto
default: 0
type: switch
section:
label: Section
nameFrom: name
descriptionFrom: slug
list: $/authorname/pluginname/models/modelname/recordfinder_columns_for_model.yaml
span: full
type: recordfinder
custom_fields:
type: nestedform
showPanel: false
dependsOn: section
trigger:
action: hide
field: section
condition: value
form:
fields:

Снимок экрана 2023-10-13 в 19 57 34

OctoberCMS 3.3.20:
I get next data:
[ string primary => 1, string section => 2, array 'custom_fields' => [] ]

OctoberCMS 3.5:
I get an unpacked array of custom_fields;
[]

@Dok2314 Dok2314 changed the title Bug in method onRelationManageCreate. Data error in a field of the nested form type when creating a model. Oct 13, 2023
@Dok2314
Copy link
Author

Dok2314 commented Oct 16, 2023

Any news?!

@daftspunk
Copy link
Member

Hi @Dok2314

Sometimes, unconventional code works because of a quirk in the design; when the quirk (bug) is fixed, the code breaks and forces you to write it according to the conventional design pattern.

In this case, your issue is probably because of the following change:

image

Here is the reason for the change:

When NestedForm is not in a relation mode, it currently doesn't process form widgets correctly and it just returns raw post data.

This causes wrong values to be stored in a database when using more complex form widgets. This PR ensures that data is correctly processed before it is returned from the getSaveValue method.

I'm not 100% sure if this is the problem with your code, but hopefully, it offers some insight into a recent change to NestedForm. If you think you've found a bug in the October CMS platform, please get in touch with the helpdesk.

@Dok2314
Copy link
Author

Dok2314 commented Oct 16, 2023

My model uses filterFields method, and in OctoberCMS 3.5, I fall into the method when i press "create", and due to changes in the getSaveValue method, I do not receive all the necessary data and get into the method, as a result I hide my own fields, before this did not happen, because all the necessary data came in. Use filterFields - it's not a unconventional code.

@daftspunk
Copy link
Member

You should be able to access via post() in filterFields, hopefully it helps as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants