Carbonfields,未定义的元素数量

Carbonfields, undefined number of elements

我正在为 wordpress 插件使用碳字段。问题是在选项中应该有未定义数量的输入。

例如(这是一种简化),在设置中有“人”,开发者可以指定多个人。

例如,字段应该是:

- Name
  Surname
  x (delete)
- Name
  Surname
  x (delete)
+ (add new person)

单击 + 后,应会出现新字段 Name、Surname、x。

我的代码现在是这样的:

 Container::make('theme_options', 'XXX')
            ->set_page_parent('options-general.php')
            ->add_tab( 'People', array(
                Field::make('text', 'xxx_name', 'Name'),
                Field::make('text', 'xxx_surname', 'Surname')
            ))

我希望配置存储在数组中

碳字段中已经有复杂字段。

Complex fields act as containers to which you can add multiple groups of fields. It is represented as a table, where each row is a field group. The user is able to add infinite rows of each group. This allows to repeat a set of fields multiple times creating customizable and sortable lists. This is useful when creating image galleries, lists of data or advanced content and layout elements.

This is the link to the documentation page

在我的例子中是这样的:

Container::make('theme_options', 'XXX')
    ->set_page_parent('options-general.php')
    ->add_tab('People', array(
        Field::make('complex', 'xxx-person', 'Person')
            ->add_fields(array(
                Field::make('text', 'xxx_name', 'Name'),
                Field::make('text', 'xxx_surname', 'Surname')
            ))
    ));