corcel / acf

Advanced Custom Fields (ACF) plugin for Corcel
126 stars 98 forks source link

ACF Group #87

Open codemonkeynorth opened 4 years ago

codemonkeynorth commented 4 years ago

would be good if we could get a Group field in the library

as far as I know it just prefixes groupname_ so if eg my Group is hero and my first field in the repeater is image then the field becomes hero_image

I had a go at adapting the Repeater field and it seemed to work using eg

protected function fetchPostsMeta($fieldName, $post) {
  ....
  $builder->where(function ($query) use ($fieldName) {
    $query->orWhere('meta_key', 'REGEXP', "^{$fieldName}_[a-z0-9]*$");
  });
protected function fetchFields ($fieldName, Builder $builder) {
  ...
  $name = str_replace($this->name."_", '', $name);
  $fields[$name] = $field->get();

I hope this of some use. It's mostly trial and error, I'm not quite sure how the whole thing fits together.