Skip to content

Repeater required fields #345

@davideprevosto

Description

@davideprevosto

I am using ACF Composer v3.4.3

I added a block and I am not able to validate the required fields.

Saving the current post, without inserting none of the required fields, it is not raising the ACF validation.

Image
/**
     * @throws FieldNameCollisionException
     */
    public function fields(): array
    {
        $fields = Builder::make(
            name: 'block_links_section_fields',
            config: [
                'title' => 'Title',
            ]
        );
        
        // icons collection
        $iconCollection = IconEnum::itemsWithDefaultValue();

        $fields
        ->addTrueFalse(
            name: 'top_position_icon',
            args: [
                'label' => 'Label',
                'ui' => true,
            ]
        )->addNumber(
            name: 'items_per_view',
            args: [
                'label' => 'Other label',
                'max' => 6,
                'min' => 1,
            ]
        )->addRepeater(
            name: 'links',
            args: [
                'label' => 'Other Label',
                'required' => true,
            ],
        )
        ->addLink(
            name: 'link',
            args: [
                'label' => 'Other Label',
                'required' => true,
            ]
        )
        ->addSelect(
            name: 'icon',
            args: [
                'choices' => $iconCollection->toArray(),
                'label' => 'Other Label',
                'ui' => true,
            ]
        )
        ->endRepeater();

        return $fields->build();
    }

Do you have any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions