Support

Account

Home Forums General Issues Generate sub field from php – check if content already exists Reply To: Generate sub field from php – check if content already exists

  • Could be interesting. But I still want to be able to check how many rows there are in a repetaer field and also check the values of the fields.

    In my first post I used the wrong function (get_sub_field), and I checked a sub field.

    if I use get_field_object on a repetaer field (which holds rows with sub fields):
    $subfield = get_field_object('pagetype1_sidebar_items');

    I get this repeater field object. But I thought it would contain the rows with the sub fields? If I var dump it I get:

    array(18) {
      ["key"]=>
      string(29) "field_pagetype1_sidebar_items"
      ["label"]=>
      string(0) ""
      ["name"]=>
      string(23) "pagetype1_sidebar_items"
      ["_name"]=>
      string(23) "pagetype1_sidebar_items"
      ["type"]=>
      string(4) "text"
      ["order_no"]=>
      int(1)
      ["instructions"]=>
      string(0) ""
      ["required"]=>
      int(0)
      ["id"]=>
      string(33) "acf-field-pagetype1_sidebar_items"
      ["class"]=>
      string(4) "text"
      ["conditional_logic"]=>
      array(3) {
        ["status"]=>
        int(0)
        ["allorany"]=>
        string(3) "all"
        ["rules"]=>
        int(0)
      }
      ["default_value"]=>
      string(0) ""
      ["formatting"]=>
      string(4) "html"
      ["maxlength"]=>
      string(0) ""
      ["placeholder"]=>
      string(0) ""
      ["prepend"]=>
      string(0) ""
      ["append"]=>
      string(0) ""
      ["value"]=>
      bool(false)
    }

    It doesn’t contain the two rows with sub fields. So this doesn’t get me the info I need – I need to check if there are rows, and if so, check the values of the rows.