• Resolved chrisjdahl

    (@chrisjdahl)


    PHP Version 7.4.3

    Update: I managed to fix this by setting the default argument to the array I was trying to use in the data argument ie: 'default' => $raffle_events

    Hi, last week my data argument for my field “bpr_events” was working right, and the options object looked like this:

    -bpr_events: [
    "activity_update"
    "activity_comment"
    "friendship_created"
    "joined_group"
    "activity_like"
    ]

    I’m not sure what happened, but now the options object looks like this:

    bpr_events: [
    [ ]
    [ ]
    [ ]
    [ ]
    [ ]
    ]

    It saves each item as an empty array.

    Here is the code:

    $raffle_events = array('activity_update', 'activity_comment', 'friendship_created', 'joined_group', 'activity_like');
    
    $raffle_events_field = array(
    	'id' => 'bpr_events',
    	'type' => 'text',
    	'data' => $raffle_events
    );
    array_push($fields_array, $raffle_events_field);
    // some other code ...
    
    Redux::set_section($opt_name, array(
    	'title'      => __('Raffle Events', 'bpr-raffle'),
    	'id'         => 'raffle_events_section',
    	'desc'       => __('Choose options for the behavior of each raffle event.'),
    	'fields'     => $fields_array,
    ));

The topic ‘data argument for Text field not rendering / saving’ is closed to new replies.