• Resolved stefanoulivieri

    (@stefanoulivieri)


    Hi all

    i’ve a post that contains a list o strings (one string for row), like this:
    bla bla bla
    ble ble ble
    blu blu blu

    then i’m trying to populate a Select field retriving those strings
    so the user can choose a string for single row
    but the output in the Select i get 1 row with all the string in it

    
    [select* show include_blank ""]
    
    [cf7-recordset id="posta-data" type="post" attributes="post_title,post_content,guid" condition="post_status='publish' AND post_type='page' AND ID='4655'"]
    
    [cf7-link-field recordset="posta-data" field="show" value="{template.post-content-summary}" keep-options]
    
    <template id="post-content-summary">
    <h2><a href="{attribute.guid}">{attribute.post_title}</a></h2>
    <p>{attribute.post_content}</p>
    </template>
    


    also, i do’t need the page title but if i don’t use it, i got nothing in the Select field

    there’s a way to reach teat goal?

    thanks in advance!

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

    (@codepeople)

    Hello @stefanoulivieri

    Thank you very much for using our plugin.

    You don’t want to use the post_content directly in the select tag choices. You want to split the texts by the changes of lines and use each row per choice. So, you must use the plugin events and functions to preprocess the RecordSet records:

    select* show include_blank ""]
    
    [cf7-recordset id="posta-data" type="post" attributes="post_title,post_content,guid" condition="post_status='publish' AND post_type='page' AND ID='4655'"]
    
    [cf7-link-field recordset="posta-data" field="show" value="value" text="text" keep-options]
    
    <script>document.addEventListener('cf7-recordset', function(evt){
        if(evt.detail['recordset-id'] == 'posta-data')
        {
            let record_rows = [], content_rows = evt.detail['recordset-data'][0]['post_content'].split(/[\\n\\r]/);
            for( var i in content_rows) record_rows.push({text: content_rows[i], value:content_rows[i]});
            cf7_datasource_set_recordset_data('posta-data', record_rows);
        }
    }); </script>

    Best regards.

    Thread Starter stefanoulivieri

    (@stefanoulivieri)

    thanks a lot!
    i missed the answer.

    now i’ll check it ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fill Select field with content from a single post’ is closed to new replies.