PDA

View Full Version : Conditional fields settings



Mustafa ilker Yonel
September 22, 2017, 12:09 PM
I saw in gerneral wide template a new field (Rent time frame) appears once you pick "Rent" for the field (Property for).

i checked the backend and I couldn't figure out how I can implement this feature.

How can I make a conditional field ?!

Mustafa ilker Yonel
September 27, 2017, 01:48 PM
i wrote my own script for this.

Wei Hong
September 27, 2017, 04:40 PM
i want to learn this trick also but it look like hard code part and I'm not good at coding. This feature should be consider in new version as it will shorten the post new listing page. Since only the part that they want to field in is showed. Other will be hidden until clicked.

Leonid Brumari
September 28, 2017, 01:16 PM
i want to learn this trick also but it look like hard code part and I'm not good at coding. This feature should be consider in new version as it will shorten the post new listing page. Since only the part that they want to field in is showed. Other will be hidden until clicked.
Agree with Wei Hong! This is going to be very useful for us.

Mustafa ilker Yonel
September 28, 2017, 01:42 PM
example Sale - Rent field (submitform)





$(document).ready(function(){

$("[name='f[sale_rent]']").on('click', function(){

//get the field value
var value = $( this ).val();

if( value == "1" ) {

//show sale fields
$( "#sf_field_keyesample1" ).parent().show();

//hide rent fields
$( "#sf_field_keyesample2" ).parent().hide();

} else {

//hide sale fields
$( "#sf_field_keyesample1" ).parent().hide();

//show rent fields
$( "#sf_field_keyesample2" ).parent().show();

}
});
});


replace keyesample1 with the key from the field you desire to hide or pop up

This code i put in the end of the <template>/js/lib.js file but i think there is a way to put it from the adminpanel direct, i saw something but i didnt test it :D

for more specific solution write back what you need.

Example: when i click this ... that should happend..

if i can i will help you guys out

Mustafa ilker Yonel
September 28, 2017, 01:48 PM
BTW this like solution to integrete in the script is to much work !

to many possible sitiuations.

you got radio text dropdown .... every fieldtype has its own handling. what i see so far ( i am not an expert, the forum staff should know better )