Deactivate and set Value

4 years 1 month ago #49116 by Bjoern
Hi,
I'm trying to set field Values (Dowdown) based on another field.
It should work like this:
1) I select in the field custom_niveau the option with the value 0.
2) Some other fields should be deactivated and their value should be set to a specific one.
3) If the field custom_niveau has another option, then the fields should be activatet again.

This is my code:
var custNiveau = document.getElementById('custom_niveau');

custNiveau.onchange = function() {
if(jQuery('#s2id_custom_niveau').select2('val') == 0){

jQuery('#s2id_custom_Dauer').select2('val', 0);
jQuery('#s2id_custom_Dauer').select2('enable', false);

jQuery('#s2id_custom_Turnus').select2('val', 0);
jQuery('#s2id_custom_Turnus').select2('enable', false);

jQuery('#s2id_custom_benotung').select2('val', 1);
jQuery('#s2id_custom_benotung').select2('enable', false);

} else {

jQuery('#s2id_custom_Dauer').select2('enable', true);
jQuery('#s2id_custom_Turnus').select2('enable', true);
jQuery('#s2id_custom_benotung').select2('enable', true);
}
};

My Problem is, that the values are set in the frontend, but when it is saved the values of the other fields are not storred in the DB. Where (how) do I have to set the values so they are storred in the DB?

Regards, Bjoern

Please Log in or Create an account to join the conversation.

4 years 1 month ago #49119 by ggppdk
Replied by ggppdk on topic Deactivate and set Value
Hello

the values will be save if they are really submitted,

maybe the problem in your case is that when form reloads they are not selected in the field, because the choice is not in the list

e.g. you can not activate choice4 if only choices:
choice1
choice2
choice3

exist


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

4 years 1 month ago #49125 by Bjoern
Replied by Bjoern on topic Deactivate and set Value
I just took a look in the DB and the values are not stored into the database. So it looks like they are not really set by the code.

Is there another field where the values have to be placed?

Please Log in or Create an account to join the conversation.

4 years 1 month ago #49133 by ggppdk
Replied by ggppdk on topic Deactivate and set Value
Hello

storing the values is the responsibility of the plugin

edit you custom field code and, please check the class method:

onBeforeSaveField(..)


compare it to other FLEXIcontent fields that are single property (per value) or multi property (per value)


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

4 years 1 month ago #49187 by Bjoern
Replied by Bjoern on topic Deactivate and set Value
I did not create a custom field. It is the standard select field (included in Flexicontent).

So I'm not using any php. Instead I try to manipulate the content within the fields via javascript only.

Can you name the javascript function for selecting a value within a select field?

Please Log in or Create an account to join the conversation.

4 years 1 month ago #49190 by ggppdk
Replied by ggppdk on topic Deactivate and set Value
Hello

i see,

for select fields we use select2 JS lib,

you should call the methods of select2 CLASS for making any changes to a form field that the select2 lib is managing it

see docs of select2 js:
http://ivaynberg.github.io/select2/


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

4 years 1 month ago #49196 by Bjoern
Replied by Bjoern on topic Deactivate and set Value
Thanks!
As you can see above, I already used the select2 class.

After some bugfixing I found the failure. I set the fields to disabled instead of readonly. I did not know that disabled fields are not send to the backend...

Now with read only it works fine.

Please Log in or Create an account to join the conversation.

4 years 1 month ago #49201 by ggppdk
Replied by ggppdk on topic Deactivate and set Value
Hello

yes, about disabled fields in HTML forms,

it is like the if field is not present in during form submit


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.