Support

Account

Home Forums Front-end Issues Preload Layout with Nested Repeater Row

Unread

Preload Layout with Nested Repeater Row

  • Hello –

    I have a frontend form showing a flexible content form. I am able to initially load the form with a basic layout to get my users started using the following:

    add_filter('acf/load_value/name=flexible', 'add_starting_repeater', 10, 3);
      function  add_starting_repeater($value, $post_id, $field) {
        if ($value !== NULL) {
          // $value will only be NULL on a new post
          return $value;
        }
        // add default layouts
        $value = array(
          array(
            'acf_fc_layout' => 'layout_1' // layout_1 is the name of the layout
          ),
          array(
            'acf_fc_layout' => 'layout_2'
          )
        );
        return $value;
      }

    etc.

    Within some of my layouts I have a repeater field. I was trying to load the layout with the first row of the repeater field also pre-loaded, so the user does not have to click Add Row. I don’t need to pre-poulate with content, I just want the first row visible.

    I noticed if you set the repeater field to a minimum row of ‘1’ this is achieved. However, I still would like to give the users the ability to delete the row should they choose not to use it.

    I just want one row of a repeater field pre-loaded to open.

    Thanks.

Viewing 1 post (of 1 total)

The topic ‘Preload Layout with Nested Repeater Row’ is closed to new replies.