Hey Arek,
Thanks for directing me to the solution... I can't find any documentation on QField on the wiki and the best I can come up with, trying to adapt my needs to the example code is something of this sort:
in PolisaInstall:
array('name'=>'Customer', 'type'=>'crm_contact', 'param'=>array('field_type'=>'select',
'required'=>true, 'extra'=>false, 'visible'=>true), 'visible'=>true, 'required'=>true, 'extra'=>false,
'display_callback'=>array('Insurance_PolisaCommon', 'display_contact_name'),
'QFfield_callback'=>array('Insurance_PolisaCommon', 'QFfield_contact_name'),
),
in PolisaCommon:
public static function display_contact_name($record, $nolink=false) {
$ret = "";
if (!$nolink) $ret .= Utils_RecordBrowserCommon::record_link_open_tag('contact', $record['customer']);
$contact = CRM_ContactsCommon::get_contact($record['customer']);
$ret .= $contact['last_name'].(($contact['first_name']!=='')?' '.$contact['first_name']:'');
$ret .= " - ".$contact['customer_id'];
if (!$nolink) $ret .= Utils_RecordBrowserCommon::record_link_close_tag();
return $ret;
}
public static function QFfield_contact_name(&$form, $field, $label, $mode, $default) {
if ($mode=='add' || $mode=='edit') {
$form->addElement('select', $field, $label);
if ($mode=='edit') $form->setDefaults(array($field=>$default));
} else {
$form->addElement('static', $field, $label);
$form->setDefaults(array($field=>self::display_contact_name(array('customer'=>$default), null, array('id'=>'customer'))));
}
}
One thing I noticed different from the ContactsCommon QField deceration for the webaddress field is that it uses addElement('text') while I obviously need it to be 'select' though, I'm probably missing some arguments there, I just don't know how it's supposed to work.
I also had to "guess" what should be the structure of the array of setDefaults() and just used 'customer' as I thought it's probably the name of the field but again, I don't know.
I'd appreciate if you can organize all of this for me.
Thanks,
Liran.