Skip to content

Instantly share code, notes, and snippets.

@techjewel
Created September 13, 2021 08:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techjewel/97fd2eb24d8895a8a4e27bbeb90ec89a to your computer and use it in GitHub Desktop.
Save techjewel/97fd2eb24d8895a8a4e27bbeb90ec89a to your computer and use it in GitHub Desktop.
Extra Form Settings for Fluent Forms
<?php
// Inject Link Form Settings Menu
add_filter('fluentform_form_settings_menu', function ($items) {
$items['my_menu_slug'] = [
'title' => 'My Menu Title',
'slug' => 'my_settings_slug'
];
return $items;
});
// Your settings callback here
add_action('fluentform_form_settings_container_my_settings_slug', function ($formId) {
$form = fluentFormApi('forms')->find($formId);
$formProperties = fluentFormApi('forms')->form($form);
// Form Inputs
$inputs = $formProperties->inputs();
$inputLabels = $formProperties->labels();
dd([$form, $inputs, $inputLabels]);
});
/*
* Helper functions for form meta for storing and getting the settings
*/
// \FluentForm\App\Helpers\Helper::setFormMeta($formId, 'YOUR_META_KEY', 'YOURMETA VALUE');
// \FluentForm\App\Helpers\Helper::getFormMeta($formId, 'YOUR_META_KEY');
@helloarpitgshah
Copy link

helloarpitgshah commented Sep 20, 2021

Hey,

Thank you for your code snippet.

But we are creating our plugin with multiple feeds as you have an option.

We need to add JS click events whenever we are going to selecting the dropdown menu from one of the feeds elements.

As like whenever users are going to select dropdowns as we need to show the text fields. We need JS code from you that can allow us to have options to make this work.

Does this make sense?

Thanks,
Arpit G Shah

@techjewel
Copy link
Author

Hi @helloarpitgshah
in the fluentform_form_settings_container_my_settings_slug you can load your own scripts and HTML or whatever you want and make the settings and UI. If you load any custom js please make sure keep the fluentform in the file name.

@helloarpitgshah
Copy link

Hey @techjewel

We have tried to add the input fields with the help of your action but it has been added at the top of every field. We need to allow them in between the other fields as we are creating the custom addon for Fluent Forms.

Is this you can help me out?

@techjewel
Copy link
Author

Hello There,
As I said, You have to use fluentform_form_settings_container_my_settings_slug action so you will get a brand new VIEW in the form the settings. Based on that you can actually output your own feed html and settings.

This is the optimal method that you can fully do whatever you want.

Regards

@helloarpitgshah
Copy link

Hey @techjewel,

Yes, But we need multiple feed options as you have in addons, that are already completed and working well. We just need to add the show/hide text field whenever a dropdown has been selected. We don't have any selector (ID/Class) for a dropdown that we can take and show/hide our text field.

Does this make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment