I want to add a dropdown to the button settings, so that the client can easily switch between 3 different button styles.
I am already changing the button output with the action “gform_submit_button”. Within this function I could apply the additional settings from the dropdown.
So the question is, if it is even possible to add additional settings to the submit button?
Here is what I have tried:
With action “gform_field_standard_settings” I added a textfield:
function pardot_standard_settings($position, $form_id) // add standard settings
{
if($position == 1500) {
?>
<li class="pardot_setting field_setting">
<label for="field_pardot_value" style="display:inline;">
<?php _e("Pardot Feld Name", "domain"); ?>
<?php gform_tooltip("form_field_pardot_value") ?>
</label>
<input type="text" id="field_pardot_value" onchange="SetFieldProperty('pardotField', this.value);" />
</li>
<?php
}
}
add_action('gform_field_standard_settings', 'pardot_standard_settings', 10, 2);
With action “gform_editor_js” I added the script:
function x_editor_script(){
?>
<script type='text/javascript'>
// adding setting to fields
fieldSettings.text += ', .pardot_setting';
fieldSettings.textarea += ', .pardot_setting';
fieldSettings.email += ', .pardot_setting';
fieldSettings.checkbox += ', .pardot_setting';
fieldSettings.checkbox += ', .pardotoutput_setting';
fieldSettings.radio += ', .pardot_setting';
fieldSettings.phone += ', .pardot_setting';
fieldSettings.number += ', .pardot_setting';
fieldSettings.select += ', .pardot_setting';
fieldSettings.consent += ', .pardot_setting';
fieldSettings.submit += ', .pardot_setting';
jQuery(document).on('gform_load_field_settings', function(event, field, form){
console.log(field);
jQuery('#field_pardot_value').val(rgar(field, 'pardotField'));
});
</script>
<?php
}
add_action('gform_editor_js', 'x_editor_script');
It works perfect for all drag-and-drop fields. But the submit button is different - the js object looks different. It does not have all the properties and therefor the value of the pardot_field does not get saved anywhere.