Exemplo n.º 1
0
 /**
  * Return a repeater field configuration array
  * @return array
  */
 public function build()
 {
     $config = parent::build();
     $fields = $this->fieldsBuilder->build();
     $config['sub_fields'] = $fields['fields'];
     if (array_key_exists('collapsed', $config)) {
         $fieldKey = $this->fieldsBuilder->getField($config['collapsed'])->getKey();
         $fieldKey = preg_replace('/^field_/', '', $fieldKey);
         $config['collapsed'] = $this->getName() . '_' . $fieldKey;
     }
     return $config;
 }
Exemplo n.º 2
0
 public function testRemoveField()
 {
     $builder = new FieldsBuilder('Banner');
     $builder->addText('title')->addWysiwyg('content');
     $builder->removeField('title');
     $config = $builder->build();
     $fields = $config['fields'];
     $this->assertCount(1, $fields);
 }
Exemplo n.º 3
0
<?php

require dirname(__FILE__) . '/../autoload.php';
use StoutLogic\AcfBuilder\FieldsBuilder;
$builder = new FieldsBuilder('banner');
$builder->addRepeater('slides')->addText('title')->addTextarea('content')->setLocation('post_type', '==', 'page');
print_r($builder->build());