Alejandro Posted January 18, 2021 at 12:08 PM Share Posted January 18, 2021 at 12:08 PM There are several inquiries hooks that can be used together to add extra fields to the form, validate them, and then include their content in the emails. Below you can find sample code that includes several different field types. This isn't a tutorial on using hooks. If you need help getting started refer to the Hooks developer documentation <?php defined('MVC_FRAMEWORK') or die; Clickfwd\Hook\Action::add('inquiry_form_top', function($params) { $Form = new FormHelper(); ?> <div class="jrFieldDiv"> <label for="jr-inquiry-phone"> <?php __t("Phone Number");?><span class="jrIconRequired"></span> </label> <?php echo $Form->text('data[Inquiry][phone]',[ 'id'=>'jr-inquiry-phone', 'class'=>'jrText', ]);?> </div> <div class="jrFieldDiv"> <label for="jr-inquiry-checkbox_example"> <?php __t("Checkbox Example");?> <span class="jrIconRequired"></span> </label> <?php echo $Form->checkbox('data[Inquiry][checkbox_example]', [ 'one'=>'One', 'two'=>'Two', 'three'=>'Three' ], [ 'id'=>'jr-inquiry-checkbox_example', 'option_class'=>'jr-option jrFieldOption', ] );?> </div> <div class="jrFieldDiv"> <label for="jr-inquiry-select_example"> <?php __t("Select Example");?>: </label> <?php echo $Form->select('data[Inquiry][select_example]', [ ''=>'Select Option', 'one'=>'One', 'two'=>'Two', 'three'=>'Three' ],$selected = '', [ 'id'=>'jr-inquiry-select_example', 'class'=>'jrSelect', ] );?> </div> <div class="jrFieldDiv"> <label for="jr-inquiry-date_example"> <?php __t("Date Example");?> </label> <?php echo $Form->text('data[Inquiry][date_example]',[ 'id'=>'jr-inquiry-date_example', 'class'=>'jrDate jr-date' ]);?> </div> <?php }); Clickfwd\Hook\Filter::add('inquiry_submit_validation', function($validation, $params) { $required = [ 'phone' => 'Phone Number', 'checkbox_example' => 'Checkbox Example', 'select_example' => 'Select Example', ]; foreach($required as $key => $text) { $found = S2Array::get($params,"data.Inquiry.{$key}"); if ( !$found ) { $validation[] = "{$text} is required"; } } return $validation; }, 10); Clickfwd\Hook\Action::add('inquiry_email_extra_fields', function($extra_fields, $params) { $fieldLabels = [ 'phone' => 'Phone Number', 'checkbox_example' => 'Checkbox Example', 'select_example' => 'Select Example', 'date_example' => 'Date Example' ]; if (empty($extra_fields)) { return; } foreach ($extra_fields as $key => $value): ?> <p><?php echo $fieldLabels[$key]; ?>: <?php echo is_array($value) ? implode(', ',$value) : $value; ?></p> <?php endforeach; }); Josh Journey and admin-1501540824 1 1 Link to comment
JAN44 Posted October 18, 2022 at 02:03 PM Share Posted October 18, 2022 at 02:03 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted October 18, 2022 at 03:24 PM Author Share Posted October 18, 2022 at 03:24 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. n00bster, Josh Journey and JAN44 1 2 Link to comment
JAN44 Posted October 19, 2022 at 06:49 AM Share Posted October 19, 2022 at 06:49 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
JAN44 Posted October 20, 2022 at 10:47 AM Share Posted October 20, 2022 at 10:47 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted October 20, 2022 at 09:53 PM Author Share Posted October 20, 2022 at 09:53 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. JAN44 1 Link to comment
JAN44 Posted October 21, 2022 at 09:31 AM Share Posted October 21, 2022 at 09:31 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted October 23, 2022 at 10:47 PM Author Share Posted October 23, 2022 at 10:47 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Josh Journey 1 Link to comment
JAN44 Posted October 24, 2022 at 10:07 AM Share Posted October 24, 2022 at 10:07 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Alejandro 1 Link to comment
Recommended Posts