I’m a Corivd novice but I’m certainly enjoying the challenge of coding many aspects of my site. I have a contact form (Wix Forms rather than custom user inputs - I’m not quite familiar with the wix-crm APIs to sync custom inputs with the contact list) set up on a dynamic page with a multiple selection field, ‘optionsGroup’, that is collapsed (set in the Properties Panel) unless a boolean criterion in the data collection (from which the dynamic page reads content) is FALSE.
import wixData from 'wix-data';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#dynamicDataset").onReady(() => {
let bool = $w("#dynamicDataset").getCurrentItem().inDevelopment;
if (bool) {
// do nothing
} else {
$w('#specificationStrip').expand();
$w('#optionsTitleStrip').expand();
$w('#optionsStrip').expand();
$w('#optionsGroup').expand();
}
// more code below
Other elements are also hidden.
I receive the following error in the Site Events log whenever the form in question is submitted, whether or not the boolean criterion is TRUE or FALSE:
"Wix code SDK Warning: The value parameter of "optionsGroup" that is passed to the value method cannot be set to null or undefined."
Everything behaves as expected, but this warning concerns me. Is there an issue with my code? Should optionsGroup be expanded by default and collapsed if bool is TRUE instead, or something else?
Firstly you are using Wix Forms which is a Wix app and not part of Corvid, of which this forum is to be used for issues related to code on your site.
https://support.wix.com/en/ascend-by-wix/wix-forms
Secondly, your Wix Forms data is added to a Submissions Table and not a dataset.
https://support.wix.com/en/article/creating-a-wix-forms-submissions-table
If you are wanting to use a dataset itself then you need to make your own user input form and connect that to a dataset.
https://support.wix.com/en/article/creating-a-form-with-user-input-elements
https://www.youtube.com/watch?v=VyMsDTwge18 - youtube video for above tutorial.
As for using it with code, well you might struggle a bit there as you are trying to interject an app with code.
You can sync your fields with some of your Contacts fields.
https://support.wix.com/en/article/syncing-your-form-with-your-contact-list-fields
This is the user inputs that you can use with your own user input form.
https://support.wix.com/en/article/about-user-input-elements
So if you used checkbox or checkbox group for example, you would need to be calling them and checking if those boolean values are true or false.
https://www.wix.com/corvid/reference/$w.Checkbox.html
https://www.wix.com/corvid/reference/$w.CheckboxGroup.html
With radio group you will need to check the needed value of those in code and the same with dropdown too.
https://www.wix.com/corvid/reference/$w.RadioButtonGroup.html
https://www.wix.com/corvid/reference/$w.Dropdown.html
As for the code sample that you have posted, you are not telling the code what to do if the boolean value is true or false, so if true then do something else if false then do something else, hence why you are getting the null return as you are not passing any value to your code.
if( $w("#myElement").collapsed ) {
$w("#myElement").expand();
}
else {
$w("#myElement").collapse();
}
Sorry but that’s no help whatsoever. Did you miss the part where I said everything works as expected?
There’s no need for your backhanded reprimand, somewhat condescening turn of phrase and almost cookie-cutter response where you just bombard me with unrelated support articles. Where did you get the impression that I am conflating the output of my form to a submisson table with the data collection my dynamic page is connected to that contains the inDevelopment property with boolean values that are used in my if/else statement?
The four elements after else { are correctly expanded if the boolean value of the inDevelopment property is not true (i.e. FALSE). If this is TRUE, the elements remain collapsed, because their default state is collapsed as set in the Properties panel.
In that sense, my code is doing exactly what I want it to do. My only concern is the SDK warning, because I do not understand what is causing it. If it can be avoided then I would like to resolve it but otherwise my site behaves as intended.