How to Set Default Form Values on Page B Based on Button Clicked on Page A?

Hello,

I’d like to ask about a specific implementation method.

We know that form fields can be set with default values. I’d like to know if it’s possible to set a default value for a Radio or Checkbox input on Page B based on a button clicked on Page A.

In other words, is there a way to pass a preset value to the form on Page B depending on which button was clicked on Page A?

Thank you very much!

Is the button you press on Page A the link that opens Page B (a-tag)? if so you could add a url-parameter like this ?changeFormDefault=Option2 and then modify the settings of your filter element like this:


add_filter('bricks/element/settings', function ($settings, $element) {

  // Swap the ID for the actual Bricks ID of your filter-element
  if ($element->id !== 'cqmlmw') return $settings;

  // Use this Helper function to dump the settings array
  Bricks\Helpers::pre_dump($settings);

  if (isset($_GET["changeFormDefault"]) && $_GET["changeFormDefault"] === 'Option2') {
    // Manipulate the settings array to your liking
  }

  return $settings;
}, 10, 2);

1 Like

Looks good!! I will give a try!!! Thank you!!!