Forums Forums Search & Filter Pro How do I get the form fieldvalues?

Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #130952

    I tried to ask the base of my question(s) in many ways already, but it seems I have to split it up in little parts to get a bit further. I am trying to use the function filter_function_name( $args, $sfid ) to do something with the fields I use in the form. The fields in the form connect with ACF fields to do the search. But I just want to access the value I instered in the frontend in the form. How do I do that?

    Thanks,

    Peter

    Trevor
    #130994

    You want to do something with the value (single value, or multi values?) from an ACF custom field after the filter has been submitted?

    If so, this thread might help:

    https://support.searchandfilter.com/forums/topic/how-can-i-display-the-selected-search-parameters-in-the-results-screen/

    Anonymous
    #131000

    I have two fields in ACF for which I use two search fields in a S&Fpro form. I want to access both fields (name and value) to do ‘something’ with it. Is that possible?

    Peter

    Trevor
    #131014

    You can access every form field using these methods. There are many threads already here with examples. The code will need to be specific to your form and the fields used. Did the thread I linked to help in any way?

    Anonymous
    #131101

    Do you want me to search everything???? I just ask for one general example to be able to get the values of search fields and use them. Already looking so much everwhere in the forum. But I don’t get it, not so experienced in PHP, so please show me how to get it done.

    Trevor
    #131105

    Hi Peter

    What do you need to do with the values? Then I can try to be more specific.

    What values are we talking about? All of them, or one of them?

    Anonymous
    #131178

    Hi Trevor,

    As I explained I have tow fields in a search form. I just want to accees those two fields and make a calculation and us the outcome in a third field.

    The first is the ‘width’ of something and the second field is the ‘height’ of something. I need to calculate height x width, so I want to pupulate the third field with that value.

    Peter

    Trevor
    #131197

    The first thing then is to find what the array (data) looks like after you submit a search (with values in those two fields). Into whichever results template you are using, I need you to add this PHP code (before the loop runs), and it will print out the array of data to your screen, which you can then post back here within code ticks (the backwards quote mark that is on the key normally to the left of the main keyboard ‘1’ key, one before the code and one after it):

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(12345)->current_query()->get_array();
    echo '<pre>',print_r($sf_current_query,true),'</pre>';
    ?>

    Where I have used 12345, you need to replace that for the ID of your form.

    Anonymous
    #131208

    I still think it’s me who is making the strange question 😉
    I hope I will give this one a last try before I have to give up, since I cannot help my customer a step further.

    I will give you a step by step list of what I have done and want to have:

    1. I just have a front end search form in which the customer uses two fields to insert the ‘height’ and the ‘width’ of something

    2. I also wnat to use S&F to search/filter on a third field (which does not need to be filled in by the customer, since that field should be the calculation of height x width. It is kind of unlogical to let the user fill in the calculated value of something so simple. Right?

    3. So I don’t need to see all the fields on the screen, I just need to get access to the two fields I mentioned. I found the names of them: _sfm_breedte (width) and _sfm_hoogte (height)

    4. I thought I could use the ‘Edit Query Arguments’ routine, and use it for the ID of my S&F serach (in my case 3954). I thought I could get the field values in that routine and make the needed calculation of the third field value there.

    5. Yes and that field might be made invisible in the front end, since the user does not need to see it. So you in ACF Pro I use the three fields, but only two shown in the search form. Ik hope that makes the appraoch for my request more clear.

    Questions:

    1. Is the routine I want to use the right one?
    2. So, how do I access and get the values of the two defined fields? I don’t need to dispaly them, just use them to make a calculation

    Example of non-PHP code in written words:

    function filter_function_name( $query_args, $sfid ) {

    //if search form ID = xxxx, the do something with this query
    if($sfid==xxxx)
    {
    get me the value of ‘height’

    }

    return $query_args;
    }
    add_filter( ‘sf_edit_query_args’, ‘filter_function_name’, 20, 2 );

    Anonymous
    #131216

    sorry, just hit the submit a bit to soon ;-), the ‘code below is what I want in that routine…..

    get me the value of ‘height’
    get me the value of ‘width”
    calculatie the value of heigh x width

Viewing 10 posts - 1 through 10 (of 11 total)