Support

Account

Forum Replies Created

  • Thanks for responding, John.

    I don’t quite understand what you’re saying.

    My challenge is to make two forms post with one submit button. I set form => false on both, add my own form tags and submit button manually, and it doesn’t work. At all. (as described above)

    And there’s nowhere in the ACF docs that I have found where this is explained.

    If you know of any such resources, I’d love to be pointed that way

    thanks!

  • The only difference between acf_form() with form set to true or false is the inclusion of the ‘<form>’ wrapper tags. Everything else about it works the same and the fields are saved in the same way they would normally be saved.

    Other than some topics you might be able to find on this forum, I don’t think there are any examples of using acf_form() this way.

    Not sure if that helps you or not.

    This is incorrect information.

    I’m searching Google now for information on how it works, and it certainly doesn’t work like this.

    Not only do I have to manually add my own form tags, I will also have to add my own submit button. I have copied the setup for both form tags and submit inputs from the standard rendering of the form, but clicking submit doesn’t save the values and I get a query string in return that’s ridiculously long.

    Documentation is lacking here. Anyway, I’m adding this in case others are searching for this response and are mislead by the answer above.

    Will write more when I figure it out.

  • Hi John, apologize for the late response.

    Here’s a short video about what I’m trying to do.

    https://vimeo.com/289890940/fab0aef3ce

    I think something may be wrong in the ACF core, but I don’t know. I may be making a mistake.

    Thank you so much!

    Eivind

  • Thank you so much for responding, John.

    I believe we’re talking about slightly different things.

    Let me share some code with you.

    $fields_goals = array(
        'ryit_user_legacy_vision', //vision
        'ryit_user_legacy_mission', //mission
        'ryit_user_goals_ten_year', //ten year goal
        'ryit_user_goals_five_year', //five year goal
        'ryit_user_goals_one_year' //one-year goal
      );
    
      $fields_interests = array(
        'ryit_user_interests_expertise', //fields of interest or skill
        'ryit_user_interests_study' //more info about your interests
      );
    
      $fields = array(array("Vision & Roadmap", $fields_goals), array("Purpose & Business", $fields_interests));
    
      $active_field = 'vision-roadmap';
      $echo .= '<div class="main" active-field="' . $active_field . '">';
      
      //Set up category tabs
      $echo .= '<ul class="tabs">';
      foreach($fields as $field) {
        $echo .= '<li id="tab-' . sanitize_title($field[0]) . '"';
        if($active_field == sanitize_title($field[0])) {
          $echo .= 'class="active"';
        }
        $echo .= '>' . $field[0] . '</li>';
      }
      $echo .= '<li id="tab-all">View all</li>';
      $echo .= '</ul>';
    
      $fields_with_val = 0;
      $fields_echo = "";
    
      //Set up fields inside categories
    
      foreach($fields as $field_group) {
        $echo .= '<div class="field-group" id="field-group-' . sanitize_title($field_group[0]) . '">';
        $fields = $field_group[1];
        $fields_echo = "";
    
        foreach ($fields as $field) {
    
          //get essential profile data
          $field_obj = get_field_object($field, 'user_' . $user_id);
          
          if(!empty($field_obj['value']) || ($user_id == $current_user_id)) {
            $fields_with_val++;
            $can_edit = ($user_id == $current_user_id) ? " can-edit" : "";
            $fields_echo .= '<div id="' . $field_obj['name'] . '" class="field' . $can_edit . '">';
            $fields_echo .= '<h3>' . $field_obj['label'] . '</h3>';
            $fields_echo .= '<div class="field-data">';
            if(empty($field_obj['value']) && ($user_id == $current_user_id)) {
              $field_echo = '<div class="field-content"><p class="instructions">Instructions: ' . $field_obj['instructions'] . '</p><p class="add-response button">Add your response</p></div>';
            }
            else {
              if(is_array($field_obj['value'])) {
                $i = 0;
                $val_output = ""; 
                foreach($field_obj['value'] as $val) {
                  if($i>0) {
                    $val_output .= ", ";
                  }
                  $val_output .= $val;
                  $i++;
                }
                $field_echo = '<div class="field-content">' . $val_output . '</div>';
              }
              else {
                $field_echo = '<div class="field-content">' . $field_obj['value'] . '</div>';
              }
            }
            $fields_echo .= $field_echo;
            //echo "user id: " . $user_id;
            //echo "current user id: " . $current_user_id;
    
            if($user_id == $current_user_id) {
              $settings = array(
                'post_id' => 'user_' . $user_id,
                'html_updated_message' => '',
                'fields' => array($field),
                'id' => 'form_' . $field_obj['name']
              );
              ob_start();
              acf_form($settings);
              $form = ob_get_clean();
              $fields_echo .= $form; 
            }
    
            $fields_echo .= '</div>'; //end field-data
            $fields_echo .= '</div>'; //end field
          }
        }

    Now, look at where I define the $fields_goals array.

    The first two array entries refer to fields ‘vision’ and ‘mission’ inside the group ‘ryit_user_legacy’ and the last three fields belong inside ‘ryit_user_goals’.

    When I define them with their alphanumeric names like this, the front end shows the values currently visible in the backend. But when I SAVE them, the values don’t change. Nothing gets saved.

    When I change to using the field KEYS however, I manage to save the values, but the values don’t show on the profile in the backend. In other words, the KEY sends the data SOMEWHERE, but it doesn’t show up on the profile.

    This seems like a bug to me, but I’m not sure.

    Everything works fine with fields which aren’t inside of groups. I’m stumped.

    Eivind

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