+ Reply to Thread
Results 1 to 8 of 8

Thread: Show/Hide field in dependence of another field value (add listing form)

  1. #1

    Show/Hide field in dependence of another field value (add listing form)

    Hello!
    How can I show/hide one field in dependence of another field value on adding listing form?
    The example of this functionality you can find on "Classified Ads" user interface demo site, adding the listing in Property/Houses category. If you select "rent" option in field "Property for" you can see new field: "Rent Time Frame", but if you select "sale" option field "Rent Time Frame" is hidden.
    How can I manage such dependencies? I failed with finding this settings in admin panel.

  2. #2
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    1,676
    Hello Alexey,

    it should be modified through the code

    Go to ftp > ... > templates > your template > js > lib.js > find a function "this.realtyPropType"
    you can add your own logic here meaning action 'hide/show' between radio values

    or use this function on the page you need, for example, add-listing form:

    go to your template > controllers > add_listing > add_listing.tpl > use at the bottom this code:

    Code:
    Only registered members can view the code.
    examples:

    <radio_field_selector> - 'div.search-item span.custom-input input[name="f[sale_rent]"]'
    <target_selector> - 'div.search-item span.custom-input input[name="f[time_frame]"]'
    <parent_class> - '.search-item'
    Last edited by Rudi; February 6, 2018 at 03:35 AM.

  3. #3
    Oh wow, I have been asking for a long time. I will save and try it out later. Thank Rudi

  4. #4
    Hello, Rudi!
    Thank you very much for the answer!
    I have already guessed that I should set up such things through the theme code thank you for the exact instruction where and how I can do it.
    I also have a new one question, on the same subject: On the page https://realty.demoflynax.com/search.html of Realty Demo we can see a search form with tabs and same dependencies as in my first question. If I am right this search form is full custom form, made through theme code rather than by admin panel. Am I right? And can you help me find the code of this form in source files of the theme?

  5. #5
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    1,676
    Quote Originally Posted by Wei Hong View Post
    Oh wow, I have been asking for a long time. I will save and try it out later. Thank Rudi
    You're welcome


    Quote Originally Posted by Alexey Merkulov View Post
    If I am right this search form is full custom form, made through theme code rather than by admin panel. And can you help me find the code of this form in source files of the theme?
    Actually, it's a standard quick form for all templates and you can manage it via AP > Forms > Search Forms > find a 'Quick' search form by the name of your listing type (in this case, Listings) > Build

    It uses 'search.tpl' which is located in templates > your template > tpl > controllers

  6. #6
    Rudi, thank you again for the answer! It is very helpful for me.
    As I can see, this is really a standard quick form, but with the same javascript modifications as the add-listing form and the tabs are made in the template.

  7. #7
    Senior Member
    Join Date
    Oct 2019
    Location
    Hungary
    Posts
    141
    I need help. Why don't you hide the field for me?
    target_selector = typeof target_selector != "undefined" ? target_selector : '#sf_field_kaukcio_frame',
    I pasted it here, but it still shows up when I shouldn’t
    this.realtyPropType = function(selector, target_selector, parent_class) {
    var selector = typeof selector != "undefined" ? selector : '#sf_field_sale_rent span.custom-input input',
    target_selector = typeof target_selector != "undefined" ? target_selector : '#sf_field_time_frame',
    target_selector = typeof target_selector != "undefined" ? target_selector : '#sf_field_kaukcio_frame',
    parent_class = typeof parent_class != "undefined" ? parent_class : '.submit-cell';

    $(target_selector).closest(parent_class).hide(0);

  8. #8
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    1,676
    It seems that you did something wrong, at least I see you define target_selector two times in your code

    You'd better create a ticket with your issue

+ Reply to Thread