Search code examples
phpwordpressadvanced-custom-fieldsacfpro

How to update complex field programmatically and keep ability for updating?


I've tried to update this way

$old_field = get_field( 'my-field', 'my-option-page' );

$my_field_structure = [
    'level-1' => [
        'level-1-1' => [
            'level-1-1-text' => 'Test 1'
        ]
    ],
    'level-2' => [
        'level-2-1' => [
            'level-2-1-text' => 'Test 2'
        ]
    ],
    // ... and so long
];

$old_field['level-1']['level-1-1']['level-1-1-text'] = 'Test 1 (Updated)';

update_field( 'my-field', $old_field, 'my-option-page' );

After this I've lost ability to update_field.

Field is always stay the same 'Test 1 (Updated)'

Neither manual admin area nor programmatically I have no ability to update field value.

Value always stay the same Test 1 (Updated)

How to properly update nested field and fix this issue?


Solution

  • The problem is max_input_vars php.ini setting.

    I've changed from 1000 to 5000 and the problem solved