Closed ghost closed 9 years ago
If the preset field does not have to be in the same page/tab with the other associated fields, it is possible with the default
argument in the field definition array. If all the configurations have to be done in one setting page and the associated fields must be changed dynamically when the preset field changes without reloading the page, the framework does not provide such functionality as built-in.
Ahh yes, that could work fine by placing the other three fields in another tab separated from the preset tab field. How do I go about passing the value of the first preset field through to the other 3 fields which would basically make the other 3 fields the default starting point? This sounds a great workaround solution from what I understand of your suggestion.
Have you made it to the point that you retrieve saved option values? If so, it should not be hard to wrap your head around.
array(
'field_id' => 'my_associated_field',
'type' => 'number',
// calculate the value with a retrieved preset value
'default' => 20 + ( int ) AdminPageFramework::getOption(
'Your_Option_Key', // the option key
array( 'my_section', 'my_preset_field' ),
30 // the default value of the preset field
),
),
If you are not setting a custom option key, the option key will be the instantiated class name.
Not yet, I am just wrapping my head around making the switch from Redux to use APF, then will start the work next week. Now that I know this is possible, I can feel more comfortable to be looking at doing this. If I fall short I will reach out only if needed. I can happily close this out.
I am wanting to setup a numeric field (for site max width) with text field as my preset for setting up width value to be used in 3 other fields. The preset field will be used for a boxed layout website, the preset field will set the header wrap, body wrap and footer wrap.
Once the preset value has added the values to the other 3 fields the end user can still edit each of the other 3 fields if they like. Is this possible with Admin Page Framework field?