Buy Now
Sign in

Json encoding now does not save as null in mysql

bensonley , March 05 2019, 15:18
B
bensonley 65
March 05 2019, 15:18 #384448
When I saved forms before with json encoded repeater areas, they saved as null in mysql if there was no data, now they are saving as "" in the same field. This has happened since the last update - any resolution to correct this or stop this from happening as it's causing major issue with all my custom code areas with logical expressions?
healyhatman 6
March 05 2019, 20:48 #384456
This is happening to me as well. {data:field/DEFAULT IF EMPTY} doesn't work properly anymore because an empty field sends a "" value instead of nothing.
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
B
bensonley 65
March 05 2019, 21:58 #384461
For now I've had to put in if($var ==='""'){...} else {...} instead of 'null' which is working for any custom code outputs, but still annoying! I've got abut 30 forms relying on this so quite some work to put right even if until a fix comes into play.
admin 27
March 07 2019, 21:46 #384545
What type of field has this issue ? an empty "text" field will send "", but an unselected checkbox with "ghost disabled" will send null and will use the default value.
Please post a test case!
Best regards
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
healyhatman 6
March 07 2019, 23:03 #384550
I might be wrong but I always though {data:field/DEFAULT} would show DEFAULT if the text field was empty.
Web developer at SkySpider.com.au
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
admin 27
March 08 2019, 08:09 #384559
 1
No, only if the value is null or if not available in the data array!
Best regards
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
B
bensonley 65
March 08 2019, 10:05 #384572
I have a text fields and dropdown fields within a repeater set which is then saved into a single column in a mysql table json encoded on save. However if the repeater isnt used CF6 used to save the value is 'null', after the update it now saves as ""
Examples:
OLD with data - [{"aid":"2248","gid":"","conf":"y","agent_access":"","type":"H","agent_id":"110","value":"","date":""}]
OLD without data - null
NEW with data - [{"aid":"2248","gid":"","conf":"y","agent_access":"","type":"H","agent_id":"110","value":"","date":""}]
NEW without data - ""
Does that help understand or do you need the form?
Thanks
admin 27
March 08 2019, 19:49 #384591
Ok, how do you get this encoded value ? and what are your fields names ?
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
B
bensonley 65
March 09 2019, 10:23 #384598
I have a repeater area , called repeater_area65, and each field setup with the syntax like:
Name :
appt[{var:area_repeater65.key}][conf]
ID :
conf{var:area_repeater65.key}
And in setup tab a Save Data action with a field setup on Data override on Insert / Update like:
appointments:{data.jsonen:appt}
admin 27
March 09 2019, 11:20 #384599
For the 2 results you have printed above (New with data and New without data), what are the contents of the data array you get when you add a "debugger" to your form ?
The data array is the first array shown on the page in the debug output!
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
B
bensonley 65
March 09 2019, 11:30 #384600
On Edit:
[appointments] => [{"aid":"2248","gid":"","conf":"y","agent_access":"","type":"H","agent_id":"110","value":"","date":""}]
On Save:
[appt] => Array
(
[0] => Array
(
[aid] => 2248
[gid] =>
[conf] => y
[change_spec] =>
[agent_access] =>
[type] => H
[agent_id] => 110
[value] =>
[date] =>
)

)
admin 27
March 09 2019, 11:31 #384601
No, I want the data array from the debugger (the top part of the debugger) when there is data and when there is no repeater data, before any json encoding is done!
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
B
bensonley 65
March 09 2019, 11:47 #384602
Sorry Max, I'm not 100% sure what you want to see, so I've opened the access for you here with debugger on and repeater area data deleted:
https://klippa-relo.com/client-bookings-area/find-asignee/edit-asignee?aid=306&event=load
Please let me know when you've had a look and I'll remove public access again.
admin 27
March 09 2019, 11:57 #384603
I get an error "column username can not be null" when I try to update the record!
I just need to check the data posted by the form when its submitted with and without the repeater.
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
B
bensonley 65
March 09 2019, 12:06 #384604
Ah, it's because you aren't logged in it uses the logged in user for a field . If you revisit the page the rest of the data is saved correctly ( inc repeater area).
If not I can send you login access and setup copies for the forms for you to change / edit as you please?
admin 27
March 09 2019, 12:10 #384606
No need for a login, just test the form twice, one time with a repeater item filled in, and one time without any repeater items, and copy here the data array contents from the debug in both cases!
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
B
bensonley 65
March 09 2019, 12:35 #384607
 1
OK, weirdly its saving this as null at the moment, which is what I want. I have another form which I'll check for the same issue, which is where I first found the problem and if it's not saving as null I'll set up the forms as requested and reply to this thread.
I've just got a lot on today which is urgent for tomorrow, so I'll finish what I have to first and then report back later.
Thanks for your help so far Max