realbig / rbm-field-helpers

0 stars 1 forks source link

Description $arg in Repeater #17

Closed d4mation closed 6 years ago

d4mation commented 8 years ago

Description doesn't appear to render. Not sure why as the Repeater just calls the Field directly.

Didn't work for either Media (Image) or Text.

rbm_do_field_repeater( 'features', false, array(
                'image' => array(
                                'type' => 'image',
                                'label' => __( 'Image', RBP_Downloads_Fields::$plugin_id ),
                                false,
                                array(
                                                'preview' => 'thumbnail',
                                                'description' => _x( 'Recommended Size: 1000px * 750px', 'Features Image Recommended Size Text', RBP_Downloads_Fields::$plugin_id ),
                                )
                ),
                'title' => array( 
                                'type' => 'text',
                                'label' => __( 'Title', RBP_Downloads_Fields::$plugin_id ),
                                false,
                                array(
                                                'description' => 'test',
                                )
                ),
                'content' => array( 
                                'type' => 'wysiwyg',
                                'label' => __( 'Content', RBP_Downloads_Fields::$plugin_id ),
                                'wysiwyg_args' => array(
                                                'tinymce' => true,
                                                'quicktags' => true,
                                ),
                ),
) );
d4mation commented 7 years ago

Revisiting this. Turns out it is due to #22. There is no $args parameter for rbm_do_field_repeater() and instead, $args gets assigned within the function to be otherwise empty outside of its defaults and the provided Fields.

d4mation commented 7 years ago

Well, that and the Repeater Class doesn't utilize $args for anything else and I just assumed it did, lol

d4mation commented 7 years ago

Workaround:

// Can't use the fancy function shorthand since we need full access to $args to set no_init
new RBM_FH_Field_Repeater( 'prefix_park_hours_exceptions', false, array(
    'no_init' => true,
    'fields' => array(
        'date' => array(
            'type' => 'datepicker',
            'label' => 'Date',
        ),
        'hours' => array(
            'type' => 'text',
            'label' => 'Park Hours',
            'args' => array(
                'default' => '9 a.m. to 5 p.m.',
            )
        )
    )
), get_option( 'prefix_park_hours_exceptions' ) );
d4mation commented 6 years ago

This is fixed in the rewrite.