Support

Account

Home Forums Front-end Issues adding select menu to front end form

Solved

adding select menu to front end form

  • hello,

    I am creating a search form in my theme. In this form I want a select menu that uses the choices from the custom field I created (see attached for custom field)

    I would also like to do this with checkboxes for another custom field.

  • 
    <?php 
      $field = get_field_object('field_XXXXXXXX'); // field key of your field
      if (!empty($field['choices'])) {
        ?>
          <select name="your-field-name">
            <?php 
              foreach ($field['choices'] as $v => $l) {
                ?><option value="<?php echo $v; ?>><?php echo $l; ?></option?<?php 
              }
            ?>
          </select>
        <?php 
      }
    
  • I know that is an old topic but it worked for me also and I have a question.
    How can we save the selected value from this select field?
    I tried with the following code but it returns null update_field($field, $field['value']

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘adding select menu to front end form’ is closed to new replies.