redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

Spacing field defaults setting and units problem

Open FrankyG opened this issue 12 years ago • 4 comments

This is my configuration for a spacing field:

    array(
        "title"             => _x( "Main area padding", "backend", "coach-theme" ),
        "desc"              => _x( "Select the top and bottom padding for the main area.", "backend", "coach-theme" ),
        "id"                => "opt_mainareapadding",
        "type"              => "spacing",
        "mode"              => "padding",
        "units"             => array('em', 'px'),
        "units_extended"    => true, 
        "top"               => true,
        "bottom"            => true,
        "left"              => false,
        "right"             => false,
        "default"           => array(
                                    'padding-top'       => '1em',
                                    'padding-bottom'    => '1em',
                                ),
        ),
  1. If I reset the section or after installation the default values will be set to 1px and 1px.
  2. I can select 10 different units (maybe because "units_extended => true), but if I set "units_extended" => false, I can still select between 5 values, not only the 2 from the "units" array.
  3. The only way I can get the default value set properly to 1em, 1em is to configure "units => 'em', but in this case I cannot select any unit, even if "units_extended" => true.

FrankyG avatar Feb 05 '14 20:02 FrankyG

In your default array, add this: 'units' => 'em'. As for the issue regarding extended units, I'll have to get back to you on that. It does seems wonky, it defaults to the five standard instead of the two specified. Probably a glitch in the logic, but I'll check into it.

kprovance avatar Feb 06 '14 21:02 kprovance

Oh, by the way, after adding the units default, you'll have to reset the section to get the default to show. :)

kprovance avatar Feb 06 '14 21:02 kprovance

Just pushed 3.1.5.9, which should take care of the select box properly listing your units. Just FYI, if you set units in your code, it overrides units_extended, so even with it set to true, it will only list the units you specify. This is (should have been originally) by design.

kprovance avatar Feb 06 '14 22:02 kprovance

Hi Kevin, thank you very much. It works great. I added the units in the default array and deleted the units_extended. It now shows the behavior I want.

FrankyG avatar Feb 07 '14 12:02 FrankyG