Peek into modules/Data/Countries/CountriesCommon_0.php
There is a QFfield_zone and country.
According to this if you'd like to add chained select field, which values depends on the other ones you should use code similar to that one
public static function QFfield_zone(&$form, $field, $label, $mode, $default, $desc) {
$param = explode('::',$desc['param']['array_id']);
foreach ($param as $k=>$v) if ($k!==0) $param[$k] = strtolower(str_replace(' ','_',$v));
$form->addElement('commondata', $field, $label, $param, array('empty_option'=>true), array('id'=>$field));
if ($mode!=='add') $form->setDefaults(array($field=>$default));
}
Where $param is
array('Countries', 'country');
Countries is the root of the commondata tree, and
country is the ID of a field that has been added to the form and we should use it's value as the next commondata tree child.
If you'll select US in
country then it will fill the data from
Countries/US commondata.
QuickForms 'commondata' element is defined in this file: modules/Utils/CommonData/qf.php
However if you'd like a more flexible solution - not only commondata based, then please review CRM_PhoneCallCommon::QFfield_phone method.
You should add a select field and use
Utils_ChainedSelectCommon::create($field, array('customer'),'modules/CRM/PhoneCall/update_phones.php',null,$form->exportValue($field));
to assign a javascript code.
'customer' here is the ID of a previous field (or fields), that will be passed to script
modules/CRM/PhoneCall/update_phones.php.
null is a place where you can pass additional params to update_phones.php script. The last param is the default value, that will be added to the select before any request will be done.
In update_phones.php you don't have to load EPESI, as this file is just included by the modules/Utils/ChainedSelect/req.php file.
You'll have two arrays available:
$_POST['values'] = json_decode($_POST['values']);
$_POST['parameters'] = json_decode($_POST['parameters']);
$values is the selected ones values and $parameters is that one, where in this example is null.
I hope you'll get it 🙂
Regards,
Adam