Support

Account

Home Forums General Issues From input (FE) to select or textarea (BE)

Solved

From input (FE) to select or textarea (BE)

  • Good morning,
    in a new project I’m working on, I need to insert an input text (or URL) field through which the user can enter his domains.

    Each time the user enters a new domain, the frontend form sends the update to the backend and populates an ACF field.

    Which field should I set in the backend?
    How do I pass the data so that each submission generates a new record in the field?

    ….

    This new ACF field, which will contain all the customer’s domains, will then be used to populate a dynamic select in the frontend through which the user will select the domain on which he wants to work.

    As a second option, I will have to allow the user to have a report of his domains to manage in the frontend.

    I hope I was clear.

    Thank you.

  • I’m not sure I completely understand, but would something like this work?

    function append_url_to_field($new_input) {
      $current_values = get_field('list_of_urls', 'option')?:'';
      if($current_values) {
        $current_values .= ',';
      }
      $current_values .= $new_input;
    }

    You create a simple ‘text’ field on an options page/or other, and simply append it the new value to the existing value.

    Whenever you want to work with the domains you can use explode(',', $field_value) to get an array of urls.

  • Thanks for the reply but, I can’t quite understand.

    So, I try to explain myself better:

    On the frontend there is an Elementor form with an input text (id=”add_dom”) field and a submit button.

    This field is dynamically linked to an ACF select field in the backend which is called “domini”.

    What I would like to achieve is that every time the user adds a domain and clicks submit, that value is passed to the backend’s ACF select field.

    BONUS: cannot enter more than 5 domains.

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

You must be logged in to reply to this topic.