Insert null into nullable int column?

namford 10 Sep, 2016
Hello,

I'm using a combination of CF and CC. In the database, my int columns are nullable, but either CF or CC is inserting zero (0) when the user does not supply a value. I want instead to insert null when no value is supplied - how can I do this, please?

If you need to know which version of CF/CC I'm on, please advise where I can find out this info.

Thank you!
Natalie
GreyHead 14 Sep, 2016
Hi Natalie,

You'll find the version numbers in the Site Admin > Extensions > Manage page.

I haven't seen this problem before and don't quite know how to fix it. With ChronoForms I'd probably check the submitted data and remove any values that need to be null using a Custom Code action. I'm not sure how you would do that with CC.. Neither of them have any code that will deliberately change values, my guess is that the 0 is added my MySQL when the submitted value is an empty string.

Bob
namford 25 Sep, 2016
Hi Bob, thanks for your reply.

I want to see the input data in 2 places:
1. after form submission, see the data CF sends to CC
2. see the SQL CC sends to DB

I've enabed debug in CC and also added debug in CF form under OnSubmit -> OnSuccess -> Debugger (enabled)

But it only shows the select statement, not the update/insert statement. What do I need to do to see the data from CF (before it goes to CC) and also the data CC writes to DB?

By the way, if I can somehow private message you, I'm happy to send you login details so you can look directly if this is easier.

Thank you
Natalie
GreyHead 25 Sep, 2016
Hi Natalie,

I think that probably the answer here is to add some Custom Code in the CF On Submit event that checks the values that are causing you problems and unsets them if there is no content - otherwise you will get an empty value saved and I'm guessing that MySQL converts that to a 0 rather than a null.

Bob
namford 25 Sep, 2016
Bob,

Thank you, I understood that from your previous post but first of all I 'd like to see what values are being passed fromCF to CC and from CC to teh database. I presume the debugging must allow me to see this information (if not, it really should do...)

Please can you tell me how to see the data submitted?

Thank you
Natalie
GreyHead 25 Sep, 2016
H Natalie,

I'm not sure that Max ever thought of that particular requirement. There are a few ways that you can work round it:

+ Add Debugger actions and a ShowStopper action before the CC action in the form On Submit event; that will stop the form completing and saving but should let you see the CF Debugger output.

+ Add an email action in the form On Submit event and add code like this to the template
<?php
echo'<div>$form->debug: '.print_r($form->debug, true).'</div>';
?>
that should allow the save to complete and will send you an email with the Debugger output.

+ Lastly instead of using the CF edit action in CC use a link to a CF form event and do the save there - that's a little more long-winded but gives you full control.

Bob
This topic is locked and no more replies can be posted.