- How do I define nested fields (e.g., repeater fields with sub-fields) in ACF Builder for Laravel?
- Use the `getField()` and `getLayout()` methods on `GroupBuilder` and `FlexibleContentBuilder` with the `->` delimiter syntax. For example, `$builder->addRepeater('sections')->addField('title', 'text')->addField('content', 'wysiwyg')` creates a repeater with nested fields. The package handles serialization automatically, but ensure your `acf_data` JSON matches the new structure.
- Is stoutlogic/acf-builder compatible with Laravel 10 and PHP 8.2+?
- The package hasn’t been updated since 2021, so compatibility with Laravel 10 or PHP 8.2+ features (like enums) isn’t guaranteed. Test thoroughly, especially if using newer Laravel features. Check the GitHub issues for unresolved conflicts.
- Can I migrate existing ACF field groups (using dot notation like `field.name`) to the new `->` syntax?
- No built-in migration tool exists, but you can manually update field names in your `acf_data` JSON. Replace `field.name` with `field->name` and validate the structure. The package doesn’t provide a direct conversion utility, so test changes in a staging environment first.
- How do I validate nested field values (e.g., required fields, max depth) in ACF Builder?
- ACF Builder doesn’t enforce validation rules natively—those are handled by ACF Pro itself. Use ACF’s built-in validation (e.g., `validate_callback` in field definitions) or Laravel’s Form Requests to validate nested data before saving. For complex cases, consider custom logic in your model observers.
- Will stoutlogic/acf-builder eventually support dot notation (e.g., `field.name`) alongside `->` syntax?
- There’s no official roadmap for dot notation support, and the current `->` delimiter was chosen to avoid conflicts with legacy field names. If you need dot notation, consider alternatives like custom serialization or a wrapper package. The package prioritizes backward compatibility over new syntax.
- How do I reuse ACF field groups across multiple Laravel projects or modules?
- ACF Builder’s fluent API makes it easy to define reusable field groups in PHP. Store configurations in a shared Composer package or Laravel module, then include them via `require` or service providers. Ensure field keys (`key` in the ACF array) are unique to avoid conflicts.
- Are there performance benchmarks for deeply nested fields (e.g., 10+ levels) in ACF Builder?
- No official benchmarks exist, but deeply nested fields may increase serialization overhead and `acf_data` JSON size. Test with your expected data structure in a staging environment. For extreme cases, consider flattening nested fields or using a dedicated NoSQL solution like MongoDB via Laravel’s Eloquent.
- How do I handle ACF field groups in Laravel Livewire or dynamic forms?
- ACF Builder works seamlessly with Livewire. Define your fields in PHP, then access them in Livewire components via `$model->acf->field_name`. For dynamic forms, use the `FlexibleContentBuilder` to create conditional layouts. Ensure your Livewire properties match the ACF field structure.
- What alternatives exist for managing ACF Pro fields in Laravel if ACF Builder lacks features?
- Alternatives include raw PHP arrays (no builder), Laravel packages like `spatie/laravel-acf` (for Eloquent integration), or custom solutions using ACF’s JSON export/import. For advanced nested fields, consider a headless CMS like Strapi or direct database handling with Laravel’s JSON columns.
- How do I test ACF Builder configurations in Laravel’s PHPUnit?
- Mock the `acf_add_local_field_group` function and assert the built array structure. Use Laravel’s `expectsJob()` for testing field group registration. For nested fields, verify serialization/deserialization by comparing JSON outputs. Example: `assertEquals($expectedArray, $builder->build());`