This is my very first plug-in so I'm going with trial & error, I have two fields a checkbox and a textbox, when I check the checkbox I have javascript that enable/disable the relative textbox.
What I do:
Here are the fields definitions:
add_settings_field(
'stwc_ft_oosn_0', // id
'Enable', // title
array( $this, 'stwc_ft_oosn_0_callback' ), // callback
'settings-admin', // page
'stwc_ft_oosn_section' // section
);
add_settings_field(
'stwc_ft_oosn_notice_1', // id
'Text', // title
array( $this, 'stwc_ft_oosn_notice_1_callback' ), // callback
'settings-admin', // page
'stwc_ft_oosn_section' // section
);
While for the javascript it is disabling by jQuery adding disabled to the textbox, when disabled I can still see the text inside the textbox when I save the settings.