php js css php js css

Changes

Changes to Page: form

220976
Today 4:31am
Guevarra, Kim
Modified page
220977
Today 4:31am
Guevarra, Kim
Modified page
Content:
Id:
/membership/form/
/membership/form/
Title:
Form
Form
Content Additional:
{"togglable_footerCTA":null,"togglable_memberCTA":"on","togglable_testCTA":null,"togglable_newslettercta":null}
{"togglable_footerCTA":null,"togglable_memberCTA":"on","togglable_testCTA":null,"togglable_newslettercta":null}
Css:
/* Membership type cards */
.template-productFlexContainer {
display: flex;
flex-wrap: wrap;
gap: 1rem;
justify-content: flex-start;
}

.template-productFlex {
position: relative;
flex: 1 1 200px;
min-width: 160px;
max-width: 280px;
padding: 1.5rem;
background-color: #ffffff;
border: 2px solid #e5e5e5;
border-radius: 0.75rem;
cursor: pointer;
transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;

&:hover {
border-color: #d91f2f;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

&.selected {
border-color: #d91f2f;
background-color: #fffde7;
box-shadow: 0 0 0 3px rgba(217, 31, 47, 0.15);
}

/* Visually hide the native radio input while keeping it accessible */
input[type="radio"] {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
opacity: 0;
}

/* Ensure the label fills the card so the whole area is clickable */
label {
display: block;
margin: 0;
cursor: pointer;

&::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
z-index: 1;
}
}

h3,
p {
position: relative;
z-index: 2;
margin: 0;
}

h3 {
margin-bottom: 0.5rem;
font-size: 1.5rem;
color: #d91f2f;
}

p {
color: #333333;
font-weight: 500;
}
}
/* Membership type cards */
.template-productFlexContainer {
display: flex;
flex-wrap: wrap;
gap: 1rem;
justify-content: flex-start;
}

.template-productFlex {
position: relative;
flex: 1 1 200px;
min-width: 160px;
max-width: 280px;
padding: 1.5rem;
background-color: #ffffff;
border: 2px solid #e5e5e5;
border-radius: 0.75rem;
cursor: pointer;
transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;

&:hover {
border-color: #d91f2f;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

&.selected {
border-color: #d91f2f;
background-color: #fffde7;
box-shadow: 0 0 0 3px rgba(217, 31, 47, 0.15);
}

/* Visually hide the native radio input while keeping it accessible */
input[type="radio"] {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
opacity: 0;
}

/* Ensure the label fills the card so the whole area is clickable */
label {
display: block;
margin: 0;
cursor: pointer;

&::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
z-index: 1;
}
}

h3,
p {
position: relative;
z-index: 2;
margin: 0;
}

h3 {
margin-bottom: 0.5rem;
font-size: 1.5rem;
color: #d91f2f;
}

p {
color: #333333;
font-weight: 500;
}
}
Js:

document.addEventListener('DOMContentLoaded', function () {
// Select all radio inputs inside .template-productFlex
const productFlexBoxes = document.querySelectorAll('.template-productFlex');

productFlexBoxes.forEach(function (box) {
const radio = box.querySelector('input[type="radio"]');

if (radio) {
// Initial state on load
if (radio.checked) {
box.classList.add('selected');
}

// Listen for changes
radio.addEventListener('change', function () {
// Remove 'selected' from all .template-productFlex elements sharing the same name
const allRadios = document.querySelectorAll(`input[name="${radio.name}"]`);
allRadios.forEach(function (r) {
const parent = r.closest('.template-productFlex');
if (parent) {
parent.classList.remove('selected');
}
});

// Add 'selected' class to the current one
if (radio.checked) {
box.classList.add('selected');
}
});
}
});
});

document.addEventListener('DOMContentLoaded', function () {
// Select all radio inputs inside .template-productFlex
const productFlexBoxes = document.querySelectorAll('.template-productFlex');

productFlexBoxes.forEach(function (box) {
const radio = box.querySelector('input[type="radio"]');

if (radio) {
// Initial state on load
if (radio.checked) {
box.classList.add('selected');
}

// Listen for changes
radio.addEventListener('change', function () {
// Remove 'selected' from all .template-productFlex elements sharing the same name
const allRadios = document.querySelectorAll(`input[name="${radio.name}"]`);
allRadios.forEach(function (r) {
const parent = r.closest('.template-productFlex');
if (parent) {
parent.classList.remove('selected');
}
});

// Add 'selected' class to the current one
if (radio.checked) {
box.classList.add('selected');
}
});
}
});
});
Php Source:
<?php

function onFormSubmit($arrValues)
{
// if user is not logged in
if (!\Components\Customers\Contacts::current())
{
$arrContact['contact_first_name'] = $arrValues['contact_first_name'];
$arrContact['contact_last_name'] = $arrValues['contact_last_name'];
$arrContact['contact_email'] = $arrValues['contact_email'];
if($arrValues['contact_password'])
{
$arrContact['contact_password'] = $arrValues['contact_password'];
}

// save first contact
$iContactId = \Components\Customers\Contacts::save($arrContact);
\Components\Customers\Contacts::currentLoginViaContactId($iContactId);
}
else
{
$iContactId = \Components\Customers\Contacts::currentContactId(true);
}

if ($arrValues['product_id'] == 389)
{
$arrPartner = $arrValues['additional_contact_partner'];
$iPartnerContactId = \Components\Customers\Contacts::save($arrPartner);
if ($iPartnerContactId)
{
\Components\Customers\Contacts\Relationships::create($iContactId, $iPartnerContactId, 'I2I_Partner');
}
}
else if ($arrValues['product_id'] == 308)
{
$i = 1;
$strFormName = 'additional_contact_family_' . $i;
while (isset($arrValues[$strFormName]))
{
$arrFamilyContact = $arrValues[$strFormName];
$strRelationship = $arrFamilyContact['relationship_type_id'];
varDump($arrFamilyContact);
unset($arrFamilyContact['relationship_type_id']);
$iFamilyContactId = \Components\Customers\Contacts::save($arrFamilyContact);

if ($iFamilyContactId)
{
\Components\Customers\Contacts\Relationships::create($iContactId, $iFamilyContactId, $strRelationship);
}
$i++;
$strFormName = 'additional_contact_family_' . $i;
}
}
}

function createCounter($last)
{
return range(1, $last);
}

function updatePreferencesOnSubmit($arrValues, $iContactId = NULL)
{
if(!$iContactId)
{
$iContactId = \Components\Customers\Contacts::currentContactId(true);
}
}

function getRelationshipCategory($strType1, $strType2)
{
if($strType1 == 'Individual' && $strType2 == 'Individual')
{
return 'I2I';
}

if($strType1 == 'Individual' && $strType2 == 'Company')
{
return 'I2C';
}

if($strType1 == 'Company' && in_array($strType2, ['Individual', '']))
{
return 'I2C';
}

if($strType1 == 'Company' && $strType2 == 'Company')
{
return 'C2C';
}

return 'I2I';
}

function getContactType($arrContact)
{
if(!is_array($arrContact))
{
$arrContact = \Components\Customers\Contacts::get($arrContact);
}

if(isset($arrContact['contact_type']))
{
return $arrContact['contact_type'];
}

return null;
}

function renderRelationship($arrContact1, $arrContact2, $strRelationshipType)
{
if(!is_array($arrContact1))
{
$arrContact1 = \Components\Customers\Contacts::get($arrContact1);
}

if(!is_array($arrContact2))
{
$arrContact2 = \Components\Customers\Contacts::get($arrContact2);
}

$strContact1Name = \Components\Customers\Contacts::renderName($arrContact1);
$strContact2Name = \Components\Customers\Contacts::renderName($arrContact2);

$strRelationshipTitle = \Components\Customers\Contacts\Relationships\Types::getColumn($strRelationshipType, 'relationship_type_title');

if(strpos($strRelationshipType, "I2C") === 0 && $arrContact1['contact_type'] == 'Company')
{
return $strContact2Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact1Name;
}

return $strContact1Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact2Name;
}

function getRelationshipTypes($iContactId1, $arrContact2)
{
$strRelationshipCategory = getRelationshipCategory(getContactType($iContactId1), getContactType($arrContact2));

$arrRelationshipTypes = \Components\Customers\Contacts\Relationships\Types::getAllForRelationshipCategory($strRelationshipCategory);

foreach ($arrRelationshipTypes as &$arrRelationshipType)
{
$arrRelationshipType['relationship_type_title'] = renderRelationship($arrContact2, $iContactId1, $arrRelationshipType['relationship_type_id']);
}

//varDump($arrRelationshipTypes);
return $arrRelationshipTypes;
}

function createRelationship($arrValues)
{
foreach($arrValues as $strField => $strValue)
{
if(str_starts_with($strField, 'contact_'))
{
$arrContact[$strField] = $arrValues[$strField];
}
}

// Try to auto merge the contact with an existing one
\Components\Customers\Contacts::autoMerge($arrContact);

$iContactId1 = $arrContact['contact_id'];
$iContactId2 = \Components\Customers\Contacts::currentContactId(true);


$arrRelationship = [];
$arrRelationship['relationship_type_id'] = 'I2I_Partner';
$arrRelationship['contact_id_1'] = $iContactId1;
$arrRelationship['contact_id_2'] = $iContactId2;
$arrRelationship['contact1_can_edit_contact2'] = 1;
$arrRelationship['contact2_can_edit_contact1'] = 0;

\Components\Customers\Contacts\Relationships::save($arrRelationship);
}

?>
<?php

function onFormSubmit($arrValues)
{
// if user is not logged in
if (!\Components\Customers\Contacts::current())
{
$arrContact['contact_first_name'] = $arrValues['contact_first_name'];
$arrContact['contact_last_name'] = $arrValues['contact_last_name'];
$arrContact['contact_email'] = $arrValues['contact_email'];
if($arrValues['contact_password'])
{
$arrContact['contact_password'] = $arrValues['contact_password'];
}

// save first contact
$iContactId = \Components\Customers\Contacts::save($arrContact);
\Components\Customers\Contacts::currentLoginViaContactId($iContactId);
}
else
{
$iContactId = \Components\Customers\Contacts::currentContactId(true);
}

if ($arrValues['product_id'] == 389)
{
$arrPartner = $arrValues['additional_contact_partner'];
$iPartnerContactId = \Components\Customers\Contacts::save($arrPartner);
if ($iPartnerContactId)
{
\Components\Customers\Contacts\Relationships::create($iContactId, $iPartnerContactId, 'I2I_Partner');
}
}
else if ($arrValues['product_id'] == 308)
{
$i = 1;
$strFormName = 'additional_contact_family_' . $i;
while (isset($arrValues[$strFormName]))
{
$arrFamilyContact = $arrValues[$strFormName];
$strRelationship = $arrFamilyContact['relationship_type_id'];
varDump($arrFamilyContact);
unset($arrFamilyContact['relationship_type_id']);
$iFamilyContactId = \Components\Customers\Contacts::save($arrFamilyContact);

if ($iFamilyContactId)
{
\Components\Customers\Contacts\Relationships::create($iContactId, $iFamilyContactId, $strRelationship);
}
$i++;
$strFormName = 'additional_contact_family_' . $i;
}
}
}

function createCounter($last)
{
return range(1, $last);
}

function updatePreferencesOnSubmit($arrValues, $iContactId = NULL)
{
if(!$iContactId)
{
$iContactId = \Components\Customers\Contacts::currentContactId(true);
}
}

function getRelationshipCategory($strType1, $strType2)
{
if($strType1 == 'Individual' && $strType2 == 'Individual')
{
return 'I2I';
}

if($strType1 == 'Individual' && $strType2 == 'Company')
{
return 'I2C';
}

if($strType1 == 'Company' && in_array($strType2, ['Individual', '']))
{
return 'I2C';
}

if($strType1 == 'Company' && $strType2 == 'Company')
{
return 'C2C';
}

return 'I2I';
}

function getContactType($arrContact)
{
if(!is_array($arrContact))
{
$arrContact = \Components\Customers\Contacts::get($arrContact);
}

if(isset($arrContact['contact_type']))
{
return $arrContact['contact_type'];
}

return null;
}

function renderRelationship($arrContact1, $arrContact2, $strRelationshipType)
{
if(!is_array($arrContact1))
{
$arrContact1 = \Components\Customers\Contacts::get($arrContact1);
}

if(!is_array($arrContact2))
{
$arrContact2 = \Components\Customers\Contacts::get($arrContact2);
}

$strContact1Name = \Components\Customers\Contacts::renderName($arrContact1);
$strContact2Name = \Components\Customers\Contacts::renderName($arrContact2);

$strRelationshipTitle = \Components\Customers\Contacts\Relationships\Types::getColumn($strRelationshipType, 'relationship_type_title');

if(strpos($strRelationshipType, "I2C") === 0 && $arrContact1['contact_type'] == 'Company')
{
return $strContact2Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact1Name;
}

return $strContact1Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact2Name;
}

function getRelationshipTypes($iContactId1, $arrContact2)
{
$strRelationshipCategory = getRelationshipCategory(getContactType($iContactId1), getContactType($arrContact2));

$arrRelationshipTypes = \Components\Customers\Contacts\Relationships\Types::getAllForRelationshipCategory($strRelationshipCategory);

foreach ($arrRelationshipTypes as &$arrRelationshipType)
{
$arrRelationshipType['relationship_type_title'] = renderRelationship($arrContact2, $iContactId1, $arrRelationshipType['relationship_type_id']);
}

//varDump($arrRelationshipTypes);
return $arrRelationshipTypes;
}

function createRelationship($arrValues)
{
foreach($arrValues as $strField => $strValue)
{
if(str_starts_with($strField, 'contact_'))
{
$arrContact[$strField] = $arrValues[$strField];
}
}

// Try to auto merge the contact with an existing one
\Components\Customers\Contacts::autoMerge($arrContact);

$iContactId1 = $arrContact['contact_id'];
$iContactId2 = \Components\Customers\Contacts::currentContactId(true);


$arrRelationship = [];
$arrRelationship['relationship_type_id'] = 'I2I_Partner';
$arrRelationship['contact_id_1'] = $iContactId1;
$arrRelationship['contact_id_2'] = $iContactId2;
$arrRelationship['contact1_can_edit_contact2'] = 1;
$arrRelationship['contact2_can_edit_contact1'] = 0;

\Components\Customers\Contacts\Relationships::save($arrRelationship);
}

?>
Handle Child Routes:
0
0
Search Title:

															

														
Search Title Prefix:

															

														
Search Description:

															

														
Search Keywords:

															

														
Search Noindex:
0
0
Search Nofollow:
0
0
Search Change Frequency:

															

														
Search Priority:
0.5
0.5
Search Canonical Override:

															

														
Is Offline:
0
0
Is Hidden In Navigation:
1
1
Is Hidden In Sitemap:
1
1
Security New:
0
0
Security Contact Mode:

															

														
Security Contact Squeeze Viewlimit:

															

														
Security Contact Require Login:

															

														
Security Contact Groups:

															

														
Security Condition Id:

															

														
Security Heading:

															

														
Security Description:

															

														
Other Fields:

															

														
Order:
0
0
Parent Id:
/membership/
/membership/
Contact Id:
0
0
Design Id:
0
0
Header Functions:

															

														
Header Category:

															

														
Is Domain:
0
0
Post Category Id:

															

														
Event Category: