Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/country_states_helper.php
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | |||||
* Prepares states dropdown based on country selected | * Prepares states dropdown based on country selected | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @param string $state_field | * @param string $state_field | ||||
* @param string $country_field | * @param string $country_field | ||||
*/ | */ | ||||
function PopulateStates($event, $state_field, $country_field) | function PopulateStates($event, $state_field, $country_field) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$country_iso = $object->GetDBField($country_field); | $country_iso = $object->GetDBField($country_field); | ||||
if ( !$country_iso ) { | if ( !$country_iso ) { | ||||
return; | return; | ||||
} | } | ||||
$field_options = $object->GetFieldOptions($state_field); | $field_options = $object->GetFieldOptions($state_field); | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @param string $state_field | * @param string $state_field | ||||
* @param string $country_field | * @param string $country_field | ||||
* @param bool $auto_required | * @param bool $auto_required | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
function CheckStateField($event, $state_field, $country_field, $auto_required = true) | function CheckStateField($event, $state_field, $country_field, $auto_required = true) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$country_iso = $object->GetDBField($country_field); | $country_iso = $object->GetDBField($country_field); | ||||
if ( $auto_required ) { | if ( $auto_required ) { | ||||
$object->setRequired($state_field, $this->CountryHasStates($country_iso)); | $object->setRequired($state_field, $this->CountryHasStates($country_iso)); | ||||
} | } | ||||
$state = $object->GetDBField($state_field); | $state = $object->GetDBField($state_field); | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |