Skip to content

Instantly share code, notes, and snippets.

@kmgdevelopment
Last active September 24, 2018 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmgdevelopment/290abdfc316ceab15134cd711ea0cf16 to your computer and use it in GitHub Desktop.
Save kmgdevelopment/290abdfc316ceab15134cd711ea0cf16 to your computer and use it in GitHub Desktop.
<?php
public function normalizeValue($value, ElementInterface $element = null)
{
$opts = $this->setOptions();
$value = array
(
'value' => $value,
'label' => $opts[$value]
);
return $value;
}
public function serializeValue($value, ElementInterface $element = null)
{
return parent::serializeValue($value['value'], $element);
}
private function setOptions()
{
include '_Regions.php';
$opts;
if( $this->regionType == 'countries' )
{
$opts = $countries;
}
elseif( $this->regionType == 'usStates' )
{
$opts = array_merge($states, $provinces);
}
return $opts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment