Skip to content

Commit

Permalink
Added option to hide form only visually
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-vince committed Jun 21, 2024
1 parent 051c882 commit 59e3097
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
29 changes: 28 additions & 1 deletion components/smallcontactform/scf-form.htm
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
{% set showForm = 1 %}
{% set hideFormVisually = 0 %}

{% if formSentAlias == __SELF__.alias and formError is empty and settingsGet('form_hide_after_success', 0) %}

{# no errors and set to hide after send #}
{% set showForm = 0 %}

{% endif %}

{% if formSentAlias == __SELF__.alias and formError is empty and (settingsGet('form_hide_after_success', 0) and settingsGet('form_hide_after_success_visually', 0) == 1) %}

{# no errors and set to hide only visually after send #}
{% set showForm = 1 %}
{% set hideFormVisually = 1 %}

{% endif %}

{% else %}

{% if showForm %}

{% if hideFormVisually %}

<div id="scf-form-{{ __SELF__ }}-hidden" style="display: none;">

{% endif %}

{{ form_open(__SELF__.getFormAttributes) }}

Expand Down Expand Up @@ -32,6 +53,12 @@

{{ form_close() }}

{% if hideFormVisually %}

</div>

{% endif %}

{% endif %}


Expand Down
3 changes: 3 additions & 0 deletions lang/cs/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@
'hide_after_success' => 'Skrýt formulář po úspěšném odeslání',
'hide_after_success_comment' => 'Po odeslání zobrazí pouze zprávu z potvrzením bez formuláře',

'hide_after_success_visually' => 'Skrýt jen vizuálně',
'hide_after_success_visually_comment' => 'Formulář bude vygenerován, ale vložen do skrytého bloku',

'add_assets' => 'Přidat doplňky',
'add_assets_comment' => 'Automaticky vloží potřebné CSS styly a JS skripty (Více informací je v souboru README.md)',

Expand Down
3 changes: 3 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
'hide_after_success' => 'Hide form after successful send',
'hide_after_success_comment' => 'Show only success message without form',

'hide_after_success_visually' => 'Hide only visually',
'hide_after_success_visually_comment' => 'Form will be rendered but inserted in hidden block',

'add_assets' => 'Add assets',
'add_assets_comment' => 'Automatically add necessary CSS and JS assets (more about assets in README.md file)',

Expand Down
11 changes: 11 additions & 0 deletions models/settings/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ tabs:
type: checkbox
tab: 'janvince.smallcontactform::lang.settings.tabs.form'

form_hide_after_success_visually:
label: 'janvince.smallcontactform::lang.settings.form.hide_after_success_visually'
comment: 'janvince.smallcontactform::lang.settings.form.hide_after_success_visually_comment'
span: right
type: checkbox
tab: 'janvince.smallcontactform::lang.settings.tabs.form'
trigger:
action: show
field: form_hide_after_success
condition: checked

form_use_placeholders:
label: 'janvince.smallcontactform::lang.settings.form.use_placeholders'
comment: 'janvince.smallcontactform::lang.settings.form.use_placeholders_comment'
Expand Down
4 changes: 3 additions & 1 deletion updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,6 @@
1.67.0:
- Updated mail templates for OC v3.6
1.67.1:
- Fixed pl language folder
- Fixed pl language folder
1.68.0:
- Added option to hide form only visually

0 comments on commit 59e3097

Please sign in to comment.