* or is not a core field on the form's entity).
* - help (option) add help to the field - e.g ['id' => 'id-source', 'file' => 'CRM/Contact/Form/Contact']]
* - template - use a field specific template to render this field
+ * - required
+ * - is_freeze (field should be frozen).
+ *
* @var array
*/
protected $entityFields = [];
$this->entityFields = [
'label_a_b' => [
'name' => 'label_a_b',
- 'description' => ts("Label for the relationship from Contact A to Contact B. EXAMPLE: Contact A is 'Parent of' Contact B.")
+ 'description' => ts("Label for the relationship from Contact A to Contact B. EXAMPLE: Contact A is 'Parent of' Contact B."),
+ 'required' => TRUE,
],
'label_b_a' => [
'name' => 'label_b_a',
* Build the form object.
*/
public function buildQuickForm() {
+ $isReserved = ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved'));
+ $this->entityFields['is_active']['is_freeze'] = $isReserved;
self::buildQuickEntityForm();
if ($this->_action & CRM_Core_Action::DELETE) {
);
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '__');
-
- // add select for contact type
- $this->add('select', 'contact_types_a', ts('Contact Type A') . ' ',
- array(
- '' => ts('All Contacts'),
- ) + $contactTypes
- );
- $this->add('select', 'contact_types_b', ts('Contact Type B') . ' ',
- array(
- '' => ts('All Contacts'),
- ) + $contactTypes
- );
-
- //only selected field should be allow for edit, CRM-4888
- if ($this->_id &&
- CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved')
- ) {
- foreach (array('contactTypeA', 'contactTypeB', 'isActive') as $field) {
- $$field->freeze();
+ foreach (['contact_types_a' => ts('Contact Type A'), 'contact_types_b' => ts('Contact Type B')] as $name => $label) {
+ $element = $this->add('select', $name, $label . ' ',
+ array(
+ '' => ts('All Contacts'),
+ ) + $contactTypes
+ );
+ if ($isReserved) {
+ $element->freeze();
}
}