acf-composer icon indicating copy to clipboard operation
acf-composer copied to clipboard

Repeater required fields

Open davideprevosto opened this issue 5 months ago • 0 comments

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?

davideprevosto avatar May 20 '25 10:05 davideprevosto