Jump to content

Dropdown in array and foreach


Arend

Recommended Posts

Struggling with a dropdown menu in a form.  What I have is a plugin for Wordpress to make extra fields in an excisting form.

The problem that the menu is not filling with values and what ever I do nothing good is happening.

Could someone please help to get on the right track? 

Greetz Arend

 

The code I am using;


 

function gma_wpjmef_frontend_add_doelgroep_info_field( $fields ) {

  $fields['job']['job_doelgroep_info'] = array(

    'label'       => __( 'Select One ', 'extra-field' ),

    'type'        => 'select',

    'required'    => false,

    'placeholder' => '',

    'omschrijving' => '',

    'priority'    => '8',

    'be' => 'Belgium',

    'lu' => 'Luxembourgh',

    'nl' => 'Netherlands' ,

    );

    foreach ($fields['job']['job_doelgroep_info'] as $key => $value) {

   echo '   <option value="<echo $value; >"<<echo $key;></option>';

  };

  return $fields;

}


 

Link to comment
Share on other sites

Thank ypu for your input.

I took a look in the templates of Wordpress and came up with a solution

This code is working for me maby someone good use this also. ;=))

 

Greetz

Arend

 

<

function gma_wpjmef_frontend_add_doelgroep_info_field( $fields ) {

  $fields['job']['job_doelgroep_info'] = array(

    'label'       => 'Select',

    'type'        => 'select',

    'required'    => false,

    'placeholder' => '',

    'omschrijving' => '',

    'priority'    => '8',

    'options'  => array(

        'option1' => 'This is option 1',

        'option2' => 'This is option 2'

      )

    );   

  return $fields;

}

>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.