Skip to content

Commit

Permalink
feature: Allow hiding specific fields in the registration form (Libre…
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieira20 committed Dec 17, 2024
1 parent 9ed39a2 commit f17b96a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Pages/RegistrationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function ProcessPageLoad()
$this->Set('RequirePhone', Configuration::Instance()->GetSectionKey(ConfigSection::REGISTRATION, ConfigKeys::REGISTRATION_REQUIRE_PHONE, new BooleanConverter()));
$this->Set('RequirePosition', Configuration::Instance()->GetSectionKey(ConfigSection::REGISTRATION, ConfigKeys::REGISTRATION_REQUIRE_POSITION, new BooleanConverter()));
$this->Set('RequireOrganization', Configuration::Instance()->GetSectionKey(ConfigSection::REGISTRATION, ConfigKeys::REGISTRATION_REQUIRE_ORGANIZATION, new BooleanConverter()));
$this->Set('HidePhone', Configuration::Instance()->GetSectionKey(ConfigSection::REGISTRATION, ConfigKeys::REGISTRATION_HIDE_PHONE, new BooleanConverter()));
$this->Set('HidePosition', Configuration::Instance()->GetSectionKey(ConfigSection::REGISTRATION, ConfigKeys::REGISTRATION_HIDE_POSITION, new BooleanConverter()));
$this->Set('HideOrganization', Configuration::Instance()->GetSectionKey(ConfigSection::REGISTRATION, ConfigKeys::REGISTRATION_HIDE_ORGANIZATION, new BooleanConverter()));

$this->_presenter->PageLoad();

Expand Down
3 changes: 3 additions & 0 deletions config/config.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
$conf['settings']['registration']['require.phone'] = 'false';
$conf['settings']['registration']['require.position'] = 'false';
$conf['settings']['registration']['require.organization'] = 'false';
$conf['settings']['registration']['hide.phone'] = 'false'; //Hide phone field when 'true', but show it when the phone is required
$conf['settings']['registration']['hide.position'] = 'false'; //Hide position field when 'true', but show it when the phone is required
$conf['settings']['registration']['hide.organization'] = 'false'; //Hide organization field when 'true', but show it when the phone is required
/**
* Error logging
*/
Expand Down
3 changes: 3 additions & 0 deletions lib/Config/ConfigKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class ConfigKeys
public const REGISTRATION_REQUIRE_PHONE = 'require.phone';
public const REGISTRATION_REQUIRE_ORGANIZATION = 'require.organization';
public const REGISTRATION_REQUIRE_POSITION = 'require.position';
public const REGISTRATION_HIDE_PHONE = 'hide.phone';
public const REGISTRATION_HIDE_ORGANIZATION = 'hide.organization';
public const REGISTRATION_HIDE_POSITION = 'hide.position';

public const LOGGING_FOLDER = 'folder';
public const LOGGING_LEVEL = 'level';
Expand Down
6 changes: 6 additions & 0 deletions tpl/register.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
</div>
</div>

{if $RequirePhone || !$HidePhone}
<div class="col-12 col-sm-6" id="phone">
<div class="form-group">
<label class="reg fw-bold" for="phone">{translate key="Phone"}{if $RequirePhone}<i
Expand All @@ -143,7 +144,9 @@
data-bv-notempty-message="{translate key=PhoneRequired}" {/if} />
</div>
</div>
{/if}

{if $RequireOrganization || !$HideOrganization}
<div class="col-12 col-sm-6" id="organization">
<div class="form-group">
<label class="reg fw-bold"
Expand All @@ -156,7 +159,9 @@
data-bv-notempty-message="{translate key=OrganizationRequired}" {/if} />
</div>
</div>
{/if}

{if $RequirePosition || !$HidePosition}
<div class="col-12 col-sm-6 " id="position">
<div class="form-group">
<label class="reg fw-bold"
Expand All @@ -168,6 +173,7 @@
data-bv-notempty-message="{translate key=PositionRequired}" {/if} />
</div>
</div>
{/if}

<div class="col-12 col-sm-6">
{if $Attributes|default:array()|count > 0}
Expand Down

0 comments on commit f17b96a

Please sign in to comment.