Top Menu

Access ACF table type custom field

21 Feb 2019 08:31 #4508 by Jaak Ivask
Access ACF table type custom field was created by Jaak Ivask
Hello,

How can I enter and/or change data in Advanced Custom Fields: Table FieldACF table type custom field:isle in my case contains 2 columns and 1-3 rows (but this can be any number of col and rows). Example custom field object output is 2 col and 2 rows.
I need access to value->body property content there each row is represented as an array.

I´ve tryed something like this
_komplekti_kuulub.subprop!value.subprop!body_*
and different serialization parameters, but this doesn't work.

How it is possible to make it work?

Example custom field array (2 col and 2 rows):
array(18) {
  ["ID"]=>
  int(2197)
  ["key"]=>
  string(19) "field_5c6d436830ce3"
  ["label"]=>
  string(17) "Komplekti kuulub:"
  ["name"]=>
  string(16) "komplekti_kuulub"
  ["prefix"]=>
  string(3) "acf"
  ["type"]=>
  string(5) "table"
 ["value"]=>
  array(2) {
    ["header"]=>
    bool(false)
    ["body"]=>
    array(2) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(35) "F7 225 mm*454 mm*36 mm paneelfilter"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(4) "1 tk"
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(30) "G3 250 mm*460 mm filterkangas
"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(4) "2 tk"
        }
      }
    }
  }
  ["menu_order"]=>
  int(0)
  ["instructions"]=>
  string(0) ""
  ["required"]=>
  int(0)
  ["id"]=>
  string(0) ""
  ["class"]=>
  string(0) ""
  ["conditional_logic"]=>
  int(0)
  ["parent"]=>
  int(2196)
  ["wrapper"]=>
  array(3) {
    ["width"]=>
    string(0) ""
    ["class"]=>
    string(15) "komplekt_andmed"
    ["id"]=>
    string(0) ""
  }
  ["use_header"]=>
  int(2)
  ["_name"]=>
  string(16) "komplekti_kuulub"
  ["_valid"]=>
  int(1)
}

Please Log in or Create an account to join the conversation.

21 Feb 2019 14:13 #4525 by Super User
Replied by Super User on topic Access ACF table type custom field
If meta key "_komplekti_kuulub" is correct then:

for 'F7 225 mm*454 mm*36 mm paneelfilter' it should be _komplekti_kuulub!value!body!0!0!c
for '1 tk' it should be _komplekti_kuulub!value!body!0!1!c

for 'G3 250 mm*460 mm filterkangas' it should be _komplekti_kuulub!value!body!1!0!c
for '2 tk' it should be _komplekti_kuulub!value!body!1!1!c

Thanks,

Please Log in or Create an account to join the conversation.

05 Mar 2019 09:30 #4873 by Jaak Ivask
Replied by Jaak Ivask on topic Access ACF table type custom field
Hello,

I can't get this to work.

In my previous post array have been obtained with ACF function:
$fields = get_field_object('komplekti_kuulub');
I started thinking that your software is not using ACF function to read out the information of the custom field. Therefore I get the same information with Wordpress function:
$fields=get_post_meta(get_the_ID(), 'komplekti_kuulub');
and the result is
array(1) {
  [0]=>
  string(210) "{"acftf":{"v":"1.2.6"},"p":{"o":{"uh":0}},"c":[{"p":""},{"p":""}],"h":[{"c":""},{"c":""}],"b":[[{"c":"F7 225 mm*454 mm*36 mm paneelfilter"},{"c":"1 tk"}],[{"c":"G3 250 mm*460 mm filterkangas\n"},{"c":"2 tk"}]]}"
}
Trying get data from field "komplekti_kuulub" with parameters
komplekti_kuulub!acftf
and serialization Json object or Json array the best I can achive is to get [object Object] as field value. Then I've added additional parameters then nothing is displayed.

How is your plugin reading complex custom fields created with very common custom fields plugin like ACF? Howto to obtain right keys to read/edit custom field values? Using different functions will give different result arrays/object then reading data.

Please Log in or Create an account to join the conversation.

05 Mar 2019 16:52 #4880 by Super User
Replied by Super User on topic Access ACF table type custom field
Hi,

try exactly as on this image.
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.094 seconds