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?

  • 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.

  • 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)

The topic ‘How to set the min and max number of rows of an repeater through a variable?’ is closed to new replies.