Support

Account

Home Forums Feature Requests How to set the min and max number of rows of an repeater through a variable?

Solved

How to set the min and max number of rows of an repeater through a variable?

    • ArtFox

    • November 1, 2018 at 6:25 pm

    Good day. Here I ran into a task that I canโ€™t decide which day. There is a repier

    array(
      'key' => 'field_af_006',
      'label' => 'Disp',
      'name' => 'af_clients',
      'type' => 'repeater',
      'sub_fields' => array(
        array(
          'key' => 'field_af_0061',
          'label' => 'Tel_1',
          'name' => 'af_phone_one',
          'type' => 'text',
          'column_width' => '',
          'default_value' => '',
          'placeholder' => '',
          'prepend' => '',
          'append' => '',
          'formatting' => 'html',
          'maxlength' => '',
        ),
        array(
          'key' => 'field_af_0062',
          'label' => 'Tel_2',
          'name' => 'af_phone_two',
          'type' => 'text',
          'column_width' => '',
          'default_value' => '',
          'placeholder' => '',
          'prepend' => '',
          'append' => '',
          'formatting' => 'html',
          'maxlength' => '',
        ),
      ),
      'min' => '',
      'row_limit' => '',
      'layout' => 'table',
      'button_label' => 'Add Row',
    ),

    It is like other fields made through the register_field_group () function.
    How do I set it the minimum and maximum number of rows through a variable whose value will be another field?

    P.S. If something is not clear, write. I don’t understand English very well. I use Google to translate.

  • You would create an acf/load_field filter (https://www.advancedcustomfields.com/resources/acf-load_field/) for the repeater field. In this filter you can get the values set in other fields and apply them to the arguments for the repeater field.

    • ArtFox

    • November 2, 2018 at 12:17 am

    This solution is not suitable, as I found another option, but now I need to get the post_id, but it needs to be output to a separate file that is outside the loop. How can this be realized?

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.