With initial values I mean the value the field gets from the HTML. In case of a select field for example, it is impossible to have no option selected. The initial field is often just the first field in select field.
So, if you are using a plugin that initializes field values after the form has loaded, clear_on_hide will still clear these values, and set them to the values defined by the HTML code, not the values defined by your third party plugin.
It’s a valid suggestion but I want to make sure that you understand the implications and are sure you need this option. I try to be careful adding more options and complexity to the plugin because I want to keep the free plugin as lean as possible.
Thread Starter
sonne
(@sonnecreativtransfer)
Dear Jules,
that’s a valid point, acutally I’ll just need input fields to be purged since these values are preset on the server side, that is before the form is loaded.
OK, not to be nagging, but I really do want to understand the use case. Could you give me a high level description of the functionality you want?
For example: I want to create a form that sells pet food. People come to the form assuming they have a cat, so the cat group is already checked and the first cat-food is already pre-checked for them. But when people change their selection to dog, I want the cat-foods to be cleared.
If this would be your use case, I’d say you don’t need the purge_on_hide option. Since the cat group will be hidden, it’s easy to filter out the selected fields in the cat group in the email message by wrapping the field with [cat-group][/cat-group].
Note that the argument I’m starting here is just to convince myself to include the feature. I want to fully stand by a decision, and be able to explain to all my users why I included a feature, before I make it. I went trough the same process before I decided to include the clear_on_hide option. I’m still not a fan of it because it introduces extra complexity and confusion, but there were some valid use cases provided so I decided to include it.
Thread Starter
sonne
(@sonnecreativtransfer)
Dear Jules,
sorry for my late reply. Indeed it is pretty similar to what you wrote. I wasn’t aware you could filter out / hide the email content in a similar way as done on the frontend, but…
Unfortunatelly, it won’t work for us for two reasons.
Some details for you to understand what we are doing: Our form is really huge, with many dependencies, etc. After it is submitted, an email (acutally two) are sent with the data formatted in a different way than on the frontend. Also, the data is saved to a database. So there are two problems with just using a group to hide content in the mail:
– I just can not hide blocks in the email since the data is structured differently.
– The data is saved to a database and the unwanted/hidden values are still present
So that’s why the fields need to be cleared/purged.
Is there any chance you’ll add that purge feature? My other option is to check all dependencies and clear all relevant fields accordingly, which I’d really love to avoid.
Thank you very much for your fast help!
I think what you are looking for is a solution where ONLY the visible fields are submitted. If we would clear all the fields on hide, this would result in the same amount of fields, but the values will just be blank. So you’ll still save all the fields to the DB, just without a value.
The idea to actually REMOVE all fields that were invisible during submission is something I have been playing with since the beginning. I will think this trough again, but calling it purge_on_hide seems a bit weird. In my opinion this should be a setting on form-level and not on group-level.
This option will add some bloat to the interface, so I think I might include it only in the PRO version of the plugin.
Note that this will most likely break all CF7 DB plugins that currently exists. These plugins will expect that each form will submit ALL the fields. I will need to check with these plugin authors and see how we can work around this.
I’m also wondering what should happen if the mail contains a field tag that was not submitted. In normal circumstances the [fieldname] would just be shown in plain text, but that’s obviously not a good idea.
It’s pretty difficult to find a solution that works for you without confusing a lot of other users that currently use the plugin.
Thread Starter
sonne
(@sonnecreativtransfer)
Dear Jules,
submitting only visible fields is not an option since our forms are pretty huge and we only show parts of the form in multiple steps to make it easier for the user. By the way, this is how I handle it on shorter forms, where I only validate the visible fields.
In the meantime, we switched the method how we preset / prepopulate the field values. The values are empty now and set by javascript after the form has loaded. So it should be fine with your plugin now.
Again, thank you for your help and your usefull plugin!