Deactivate and set Value

More
9 years 7 months 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:
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.

More
9 years 7 months 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...

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

More
9 years 7 months 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.

More
9 years 7 months 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...

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

More
9 years 7 months 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.

More
9 years 7 months 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:
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...

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.491 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline