Support

Account

Home Forums Add-ons Flexible Content Field Populate Flexible Content Rows Programmatically Reply To: Populate Flexible Content Rows Programmatically

  • Figured I’d add something to help people out who want to add a row to a flexible content field that’s inside of another flexible content field.

    acf.addAction( 'append', function( $el ) {
    	if ( $( $el ).hasClass( 'layout' ) && $( $el ).is( '[data-layout="level1_layout_name_here"]' ) ) {
    		var nestedFlexField = acf.getField( $( '.acf-field[data-name="NESTED_FLEX_FIELD_NAME"]', $el ) );
    		nestedFlexField.add( {
    			layout: 'level2_layout_name_here'
    		} );
    	}
    } );