• Resolved EmperorFPM

    (@emperorfpm)


    I just don’t get it. The “test data source” returns correct results. No errors in console or debug but will not show up using this:

    [select vehicleyears][cf7-recordset id=”cf7-recordset-284″ type=”database” query=”SELECT DISTINCT year FROM car_db”][cf7-link-field recordset=”cf7-recordset-284″ field=”vehicleyears” value=””]

    Any help would be appreciated, testing this on local currently and have the CF7 Smart Grid extension in use.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @emperorfpm

    Thank you very much for using our plugin. The [cf7-link-field] tag requires you to enter the value and text attributes with the columns in the recordset tag.

    So, the form structure would be:

    
    [select vehicleyears]
    [cf7-recordset id="cf7-recordset-284" type="database" query="SELECT DISTINCT year FROM car_db"]
    [cf7-link-field recordset="cf7-recordset-284" field="vehicleyears" value="year" text="year"]

    I’m assuming your query is correct, and the car_db table is in the same website’s database.

    Best regards.

    Thread Starter EmperorFPM

    (@emperorfpm)

    Thanks for the reply, it was actually the value=”year” and text=”year” that were missing and that is why the data was there but wouldn’t display. Didn’t realize it need to match the DB query and not the field.

    Here is complete working:

    Car Years

    [select caryears select2]

    [cf7-recordset id=”car-years” type=”database” query=”SELECT DISTINCT year FROM car_db”]

    [cf7-link-field recordset=”car-years” field=”caryears” value=”year” text=”year”]

    And now I’m trying to get the year to create a database query so I can get the ‘make’ of cars from the ‘year’ entered by user

    Plugin Author codepeople

    (@codepeople)

    Hello @emperorfpm

    If year and make are columns in the same car_db table, you don’t need another [cf7-recordset] tag, only edit the query and insert a second [cf7-link-field] tag, as follows:

    
    [select caryears select2]
    [select carmakes select2]
    
    [cf7-recordset id="car-years" type="database" query="SELECT DISTINCT year, make FROM car_db"]
    
    [cf7-link-field recordset="car-years" field="caryears" value="year" text="year"]
    [cf7-link-field recordset="car-years" field="carmakes" value="make" text="make" condition="record['year'] == {field.caryears}"]

    Best regards.

    Thread Starter EmperorFPM

    (@emperorfpm)

    That is super helpful to know, thank you.

    This == {field.caryears}”] isn’t being seen, I tried to span it and use a do_shortcode but those didn’t work

    Plugin Author codepeople

    (@codepeople)

    Hello @emperorfpm

    I’m sorry, I don’t know what you mean with:

    >> This == {field.caryears}"] isn’t being seen, I tried to span it and use a do_shortcode but those didn’t work

    Best regards.

    Thread Starter EmperorFPM

    (@emperorfpm)

    it’s showing up on the page and not being executed. I’ve also just discovered another issue. I’m trying to have a user select a Year and then the Models of Cars from that Year will populate the next Select and then from the choice of Models the next Select (Makes) is populated.

    Right now using this:

    Year of Car [select caryears select2]

    Make of Car [select carmakes select2]

    Model of Car [select carmodels select2]

    [cf7-recordset id=”car-years” type=”database” query=”SELECT DISTINCT year, make, model FROM car_db”]

    [cf7-link-field recordset=”car-years” field=”caryears” value=”year” text=”year”]

    [cf7-link-field recordset=”car-years” field=”carmakes” value=”make” text=”make” condition=”record[‘year’] == {field.caryears}”]

    [cf7-link-field recordset=”car-years” field=”carmodels” value=”model” text=”model” condition=”record[‘make’] == {field.carmakes}”]

    All of the models from every make of car is being shown in the last select field.

    Do I need to do separate query to keep them isolated to the previous query results?

    Plugin Author codepeople

    (@codepeople)

    Hello @emperorfpm

    I see what is happening, I’m inserting the symbols [ and ] encoded, but the WordPress editor is transforming them again into [].

    It is not possible to include additional [] symbols into shortcode attributes.

    So, to avoid the editor replacing the symbols again, I’ll include the code as an image:

    Please, look as I used two conditions in the last [cf7-link-field] tag.

    Best regards.

    Thread Starter EmperorFPM

    (@emperorfpm)

    I’ll say your effort and support get you 5+ stars and I’ll make sure to review the plug-in.

    That said it still doesn’t work ??

    I’ll keep working on it but not sure what to even look at next.

    If I find a solution, I’ll update, if you have any other ideas I’d be appreciative.

    Plugin Author codepeople

    (@codepeople)

    Hello @emperorfpm

    Could you please indicate the URL to the page that contains the form to check your code in action?

    Best regards.

    Thread Starter EmperorFPM

    (@emperorfpm)

    I ran out of time yesterday but here is live URL for the form

    https://financialexaminer.com/test-car-choice/

    Plugin Author codepeople

    (@codepeople)

    Hello @emperorfpm

    Thank you very much for sending me the URL.

    Please, look at the following screenshot:

    As you can see, the shortcodes for the [cf7-link-field] fields are broken. That happens if you include the “[” or “]” symbols as part of their attributes’ values.

    Pay attention to the following image where these symbols are encoded:

    When you insert the fields through the plugin interface, it encodes the symbols for you.

    Best regards.

    Thread Starter EmperorFPM

    (@emperorfpm)

    I’ll try a couple more things.

    • This reply was modified 1 year, 7 months ago by EmperorFPM.
    Thread Starter EmperorFPM

    (@emperorfpm)

    Copied verbatim from the image – no luck

    Used a fresh basic WP install with only CF7 and this – no luck

    Not sure what else I can, seems like a really good idea for a plugin and I wish I could sort it out.

    Thanks for all your help so far

    Plugin Author codepeople

    (@codepeople)

    Hello @emperorfpm

    Could you please try the alternative notation?

    Year of Car [select caryears select2]
    
    Make of Car [select carmakes select2]
    
    Model of Car [select carmodels select2]
    
    [cf7-recordset id="car-years" type="database" query="SELECT DISTINCT year, make, model FROM car_db"]
    
    [cf7-link-field recordset="car-years" field="caryears" value="year" text="year"]
    
    [cf7-link-field recordset="car-years" field="carmakes" value="make" text="make" condition="record.year == '{field.caryears}'"]
    
    [cf7-link-field recordset="car-years" field="carmodels" value="model" text="model" condition="record.make == '{field.carmakes}'"]

    Best regards.

    Thread Starter EmperorFPM

    (@emperorfpm)

    1000 STARS!!

    That did it. It now works as I knew it could.

    Thanks for your help.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Dropdown Select using DB data’ is closed to new replies.