Skip to content

Commit 820b2e5

Browse files
committed
✨ Enhance form handling by adding translation support and improving template variable management 🎉🔧
1 parent b9e426a commit 820b2e5

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

lhc_web/lib/core/lhform/lhformrenderer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,11 @@ public static function storeCollectedInformation($form, $collectedInformation, $
10061006

10071007
// Inform user about filled form
10081008
erLhcoreClassChatMail::informFormFilled($formCollected,array('email' => self::$mainEmail));
1009+
1010+
$translationArgs = array('form' => $form);
1011+
$translationArgs['form_collected'] = $formCollected;
1012+
1013+
$form->post_content = erLhcoreClassGenericBotWorkflow::translateMessage($form->post_content, array('args' => $translationArgs));
10091014
}
10101015

10111016
}

lhc_web/modules/lhform/fill.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,21 @@
1515
}
1616

1717
if (isset($_GET['chat_id']) && is_numeric($_GET['chat_id']) && ((($chat = erLhcoreClassModelChat::fetch($_GET['chat_id'])) instanceof erLhcoreClassModelChat && isset($_GET['hash']) && $chat->hash == $_GET['hash'] && $chat->status !== erLhcoreClassModelChat::STATUS_CLOSED_CHAT) || ($form->form_type == erLhAbstractModelForm::FORM_TYPE_INTERNAL && erLhcoreClassUser::instance()->hasAccessTo('lhform', 'fill_private')))) {
18+
$replace_array = array(
19+
'{hash}' => (isset($_GET['hash']) ? $_GET['hash'] : ''),
20+
'{chat_id}' => $_GET['chat_id'],
21+
);
22+
$tpl->set('replace_array',$replace_array);
1823
$tpl->setArray(array(
1924
'hash' => (isset($_GET['hash']) ? $_GET['hash'] : ''),
2025
'chat_id' => $_GET['chat_id'],
2126
));
2227
} if (isset($_POST['chat_id']) && is_numeric($_POST['chat_id']) && ((($chat = erLhcoreClassModelChat::fetch($_POST['chat_id'])) instanceof erLhcoreClassModelChat && isset($_POST['hash']) && $chat->hash == $_POST['hash'] && $chat->status !== erLhcoreClassModelChat::STATUS_CLOSED_CHAT) || ($form->form_type == erLhAbstractModelForm::FORM_TYPE_INTERNAL && erLhcoreClassUser::instance()->hasAccessTo('lhform', 'fill_private')))) {
28+
$replace_array = array(
29+
'{hash}' => (isset($_POST['hash']) ? $_POST['hash'] : ''),
30+
'{chat_id}' => $_POST['chat_id'],
31+
);
32+
$tpl->set('replace_array',$replace_array);
2333
$tpl->setArray(array(
2434
'hash' => (isset($_POST['hash']) ? $_POST['hash'] : ''),
2535
'chat_id' => $_POST['chat_id'],
@@ -41,8 +51,8 @@
4151
$tpl->set('content',$form->content_rendered);
4252

4353
if (erLhcoreClassFormRenderer::isCollected()) {
44-
erLhcoreClassFormRenderer::storeCollectedInformation($form, erLhcoreClassFormRenderer::getCollectedInfo(), erLhcoreClassFormRenderer::getCustomFields());
45-
}
54+
erLhcoreClassFormRenderer::storeCollectedInformation($form, erLhcoreClassFormRenderer::getCollectedInfo(), erLhcoreClassFormRenderer::getCustomFields());
55+
}
4656

4757
$tpl->set('form',$form);
4858

0 commit comments

Comments
 (0)