Expand/collapse getSubscribers form

I try to hide a getSubsrcibers form connected to a switch (so when you select the switch the box appears and when you select it again it disappears). This is the code:

export function switch1_click(event) {
if ($w(‘#switch1’).checked)
$w(‘#getSubscribers1’).collapse()
else
$w(‘#getSubscribers1’).expand()
}

Now the strange things is: the code works and if I subscribe my email gets added to the form/dbase. BUT, in the code panel I get the notification
‘collapse’ does not exist on ‘getSubscribers1’ .
Can anyone explain me why and if I need to change something?

Thanks in advance!

Hey Mark!

What kind of component is $w(‘#getSubscribers1’)?
Please share a link to your site and specify on which page the code exists.
Rest assured that only authorized personnel are able to inspect your site and see your editor.

Doron.

Hi Doron, it is a (standard) contact form (add/ contacts form/ subscribe). Site is not live yet because I’m testing all kinds of stuff. I’ve set the properties to ‘collapsed on load’ by the way. As I said, it’s working well, it’s just strange I get the error messages…

When I replace it with a simple shape (to test the effect) the error messages disappear, so it looks like you normally can’t use a form for this kind of action but still works fine. Strange…

Hey Mark!

You can also share a link to your editor.
Again, only authorized personnel (Wix employees) can use this link and inspect your site.

You can also send some screenshots of the issue so we can visualize what you’re dealing with.

Doron.

Hi Doron, please check this: https://wixxim.wixsite.com/website/test-newsletter I’ve put it on a separate page so you won’t get lost in all my little ‘trial and errrors’:wink:

Hey Mark!

I tried the functionality on the test page you’ve shared.
Everything seems to work as expected.

Sometimes when a new feature/component is being released the IDE (your code platform) still shows some errors due to its unfamiliarity with the new element.
Thanks for letting us know regarding this, I’ll make sure it is fixed but rest assure it does not affect your site performance and you can just disregard this error.

Doron.

Isn’t the #getSubscribers element, just the get subscribers form from Wix Forms app.
https://support.wix.com/en/article/adding-and-setting-up-a-get-subscribers-form

With of course, Wix Forms app being a Wix app and not being part pf Wix Corvid and therefore not supposed to be used with Corvid.

‘collapse’ does not exist on ‘getSubscribers1’ .
So maybe this error is just that the Get Subscribers Form from the Wix Forms app is not supposed to be setup with the code functions of collapse/expand or hide/show as it is designed to be shown as a permanent feature on the website.

Obviously, when the user changed the Wix Form to something from within the Wix Editor, then it will not have that error as it is an element that is allowed to have the code functions of collapse etc.

The easiest option here would be not to use Wix Forms and the submission table for it and to create their own custom coded subscriber form, which will give them complete control over everything with the form itself and the dataset used for it.

Mark, just in case you are wondering, setting up your own subscribers form is easy.

I have one below through code that is on the same page as a contact us form and the code is below,
(A triggered email is sent to the user after the form is submitted and saved, hence the onAfterSave.)

import wixCRM from 'wix-crm';

$w.onReady(function() {
$w("#PublicContactUs").onAfterSave(() => {
let name = $w('#publiccontactName').value;
let email = $w("#publiccontactEmail").value;
let subject = $w("#publiccontactSubject").value;
let message = $w("#publiccontactMessage").value;
let label = ["Contacted Us"];

wixCRM.createContact({
"name": name,
"emails": [email]

})
.then((contactId) => {
// Need to use the triggered email name
return wixCRM.emailContact('publiccontactus', contactId, {
"variables": {
// Need to use the triggered email variable names
"name": name,
"email": email, // << - correct variable is email not emails
"subject": subject,
"message": message
}
});
})
.catch((err) => {
// handle the error if the email wasn't sent
console.log(`Error: ${err}`);
});
});
});

$w("#NewSubscriber").onAfterSave(() => {
let name = $w("#newsubscriberName").value;
let email = $w("#newsubscriberEmail").value;
let privacyPolicy = $w("#newsubscriberPrivacy").value;
let label = ["Subscribed"];

wixCRM.createContact({
"name": name,
"emails": [email]

})
.then((contactId) => {
// Need to use the triggered email name
return wixCRM.emailContact('newsubscriber', contactId, {
"variables": {
// Need to use the triggered email variable names
"name": name,
"email": email, // << - correct variable is email not emails
//"privacyPolicy": privacyPolicy << - not defined in the triggered email
}
});
})
.catch((err) => {
// handle the error if the email wasn't sent
console.log(`Error: ${err}`);
});
});

Thanks! Indeed I opted for the 'lazy’option here but your option is more interesting I guess because then you’re completely free with your data and such. Thanks again!

Thanks Doron!