From d7e7d248cbe41cd7a9ef9c2fb022b6c4831f99a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 31 May 2026 15:22:56 +0000
Subject: [PATCH] =jakevan complete
---
src/forms/render.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/src/forms/render.php b/src/forms/render.php
new file mode 100644
index 0000000..9865bf3
--- /dev/null
+++ b/src/forms/render.php
@@ -0,0 +1,55 @@
+<?php
+if (!defined('ABSPATH')) {
+ exit; // Exit if accessed directly
+}
+/**
+ * Form Block Render
+ *
+ * @package Edmonton_Ink
+ */
+
+/**
+ * Renders the form block on the frontend
+ *
+ * @param array $attributes The block attributes.
+ * @param string $content The block content.
+ * @param WP_Block $block The block instance.
+ * @return string The rendered output.
+ */
+function jvbRenderFormBlock(array $attributes, string $content, WP_Block $block):string
+{
+ // Get form type from attributes
+ $form_type = isset($attributes['formType']) ? $attributes['formType'] : '';
+
+ // If no form type selected, return a message
+ if (empty($form_type)) {
+ return '<div class="jvb-form-error">No form type selected. Please edit this block and select a form type.</div>';
+ }
+
+ // Get other attributes
+ $show_labels = isset($attributes['showLabels']) ? $attributes['showLabels'] : true;
+ $custom_email_to = isset($attributes['customEmailTo']) ? $attributes['customEmailTo'] : '';
+
+ // Set custom options for the form
+ $form_options = array();
+
+ // Set custom email recipient if provided
+ if (!empty($custom_email_to)) {
+ $form_options['email_to'] = $custom_email_to;
+ }
+
+ // Render the form with the specified options
+ $form_output = JVB()->forms()->renderForm($form_type);
+
+ // Get block classes
+ $wrapper_attributes = get_block_wrapper_attributes([
+ 'class' => 'jvb-forms'
+ ]);
+
+ // Return the wrapped form
+ return sprintf(
+ '<div %1$s>%2$s</div>',
+ $wrapper_attributes,
+ $form_output
+ );
+}
--
Gitblit v1.10.0