• Resolved jackbluehouse2019

    (@jackbluehouse2019)


    Hi contact form 7 specialists,
    I need a dropdown menu with dynamic text to fill options.
    So I have this shortcode in my custom plugin which should replace the dropdown menu:

    	function choix_aile($atts) {
    	
    	$content ="<select required name='aile' >
    	<option> lulu
    	<option> toto
    	</select>";
    		return($content) ;
    	}
    	add_shortcode('choix_aile', 'choix_aile');
    

    and a dynamictext field in a contact form like so:

    <label> Aile-2
    [dynamictext aile_2 “choix_aile”]</label>

    but it doesn’t work.
    If I replace the return($content) by echo in my shortcode the dropdown menu is displayed but outside of the contact form.
    What should I do?
    Thanks
    Jacques

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @jackbluehouse2019,

    Maybe this code snippet may help you achieve what you need: Create radiobuttons with custom post type.

    See also Adding a custom form-tag.

    Best regards,
    Yordan.

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    Hi Yordan,
    normally I would use a dropdown menu field but I would like the menu items to be dynamic ie contain variables instead of hard text. So I create a dropdown menu in my custom plugin and I send it in my CF7 form via the dynamichidden field. The problem is that this dropdown menu does appear on the page but outside the CF7 form as if it was not contained by the DIV of the form.
    This is the shortcode function:

    function choix_aile($atts) {
    
    	echo "
    	<form action='' method='post' id = 'bibliotheque'>
    	<select required name='aile' >
    	<option> lulu</option>
    	<option> toto</option>
    	</select>";
    	
    	}
    	add_shortcode('choix_aile', 'choix_aile');
    

    and this is the CF7 form code:

    [dynamichidden aile_2 "choix_aile"]
    
    <label> Date du vol 
    [date* date]</label>
    
    <label> Déco
    [text* deco]</label>
    </label>
    
    <label> Durée du vol (hh:mm)
    [text* duree]</label>
    
    <label> Distance
    [text* distance]</label>
    
    <label> Trace
    [file Trace limit:2000000 filetypes:igc]
    </label>
    
    [dynamichidden see_trace "CF7_GET key='see_trace'"]
    
    [dynamichidden pilote "CF7_GET key='pilote'"]
    
    [submit "Envoyer"]
    

    I maybe can use the reate-radiobuttons-with-custom-post-type code but I don’t see how to adapt it for my case (it displays posts titles where I would like to display variable contents).

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    It’s ok, I solved my problem.
    I removed my shortcode from CF7 form and I added this shortcode right before the CF7 shortcode form in the same DIV.
    The selector is displayed and the choice is taken by the CF7 form.
    So now I have a dropdown module with dynamich items.
    Just what I needed.
    I hope this helps.
    Jacques

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    Topic Solved!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘shortcode’ is closed to new replies.