For core fields, applies to primaryKey fields and fields tagged <readonly>.
For custom fields, this comes through via the 'is_view' property.
This will help autogenerated forms to know whether a field is appropriate to show to the user.
*
* Generated from xml/schema/CRM/Contact/Contact.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:d72db3da5f0a3646c35296c43880b425)
+ * (GenCodeChecksum:cfed69c9e09acada46340971415ec767)
*/
/**
'html' => [
'type' => 'Number',
],
+ 'readonly' => TRUE,
'add' => '1.1',
],
'contact_type' => [
'labelColumn' => 'label',
'condition' => 'parent_id IS NULL',
],
+ 'readonly' => TRUE,
'add' => '1.1',
],
'contact_sub_type' => [
'html' => [
'type' => 'Text',
],
+ 'readonly' => TRUE,
'add' => '1.1',
],
'display_name' => [
'html' => [
'type' => 'Text',
],
+ 'readonly' => TRUE,
'add' => '1.1',
],
'nick_name' => [
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'localizable' => 0,
+ 'readonly' => TRUE,
'add' => '1.1',
],
'api_key' => [
'html' => [
'label' => ts("Modified Date"),
],
+ 'readonly' => TRUE,
'add' => '4.3',
],
];
$field['cols'] = isset($fieldXML->html) ? $this->value('cols', $fieldXML->html) : NULL;
break;
- break;
-
case 'datetime':
$field['sqlType'] = $field['phpType'] = $type;
$field['crmType'] = 'CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME';
}
$field['headerPattern'] = $this->value('headerPattern', $fieldXML);
$field['dataPattern'] = $this->value('dataPattern', $fieldXML);
+ $field['readonly'] = $this->value('readonly', $fieldXML);
$field['uniqueName'] = $this->value('uniqueName', $fieldXML);
$field['uniqueTitle'] = $this->value('uniqueTitle', $fieldXML);
$field['serialize'] = $this->value('serialize', $fieldXML);
'title' => empty($field['name']) ? NULL : ucwords(str_replace('_', ' ', $field['name'])),
'entity' => $this->getEntityName(),
'required' => FALSE,
+ 'readonly' => FALSE,
'options' => !empty($field['pseudoconstant']),
'data_type' => \CRM_Utils_Array::value('type', $field, 'String'),
], array_flip($fields));
'name' => 'entity',
'data_type' => 'String',
],
+ [
+ 'name' => 'readonly',
+ 'data_type' => 'Boolean',
+ ],
];
}
*/
protected $columnName;
+ /**
+ * @var bool
+ */
+ protected $readonly = FALSE;
+
/**
* Aliases for the valid data types
*
return $this;
}
+ /**
+ * @return bool
+ */
+ public function getreadonly() {
+ return $this->readonly;
+ }
+
+ /**
+ * @param bool $readonly
+ * @return $this
+ */
+ public function setreadonly($readonly) {
+ $this->readonly = (bool) $readonly;
+
+ return $this;
+ }
+
/**
* @return string|NULL
*/
if ($action !== 'create') {
$idField = new FieldSpec('id', $spec->getEntity(), 'Integer');
$idField->setTitle(ts('Custom Value ID'));
+ $idField->setreadonly(TRUE);
$spec->addFieldSpec($idField);
}
$entityField = new FieldSpec('entity_id', $spec->getEntity(), 'Integer');
$entityField->setTitle(ts('Entity ID'));
$entityField->setRequired($action === 'create');
$entityField->setFkEntity('Contact');
+ $entityField->setreadonly(TRUE);
$spec->addFieldSpec($entityField);
}
$field->setHelpPre($data['help_pre'] ?? NULL);
$field->setHelpPost($data['help_post'] ?? NULL);
$field->setOptions(self::customFieldHasOptions($data));
+ $field->setreadonly($data['is_view']);
}
else {
$name = $data['name'] ?? NULL;
$field->setTitle($data['title'] ?? NULL);
$field->setLabel($data['html']['label'] ?? NULL);
$field->setOptions(!empty($data['pseudoconstant']));
+ $field->setreadonly(!empty($data['readonly']));
}
$field->setSerialize($data['serialize'] ?? NULL);
$field->setDefaultValue($data['default'] ?? NULL);
this.add = null;
this.fields = null;
- crmApi4(model.entity, 'getFields', {action: 'update', loadOptions: ['id', 'name', 'label', 'description', 'color', 'icon']})
- .then(function(fields) {
+ crmApi4(model.entity, 'getFields', {
+ action: 'update',
+ loadOptions: ['id', 'name', 'label', 'description', 'color', 'icon'],
+ where: [["readonly", "=", false]],
+ }).then(function(fields) {
ctrl.fields = fields;
});
if (fieldInUse(item.name)) {
formatted.disabled = true;
}
- if (item.name !== 'id') {
- result.push(formatted);
- }
}, []);
return {results: results};
};
<html>
<type>Select</type>
</html>
+ <readonly>true</readonly>
<add>1.1</add>
<change>3.1</change>
<contactType>null</contactType>
<type>Text</type>
<size>30</size>
</html>
-
+ <readonly>true</readonly>
<export>true</export>
<comment>Name used for sorting different contact types</comment>
<add>1.1</add>
<type>Text</type>
<size>30</size>
</html>
-
+ <readonly>true</readonly>
<export>true</export>
<comment>Formatted name representing preferred format for display/print/other output.</comment>
<add>1.1</add>
<add>1.1</add>
<change>1.5</change>
<export>true</export>
+ <readonly>true</readonly>
</field>
<index>
<name>index_hash</name>
<html>
<label>Modified Date</label>
</html>
+ <readonly>true</readonly>
<add>4.3</add>
</field>
<index>
{/if}
{if $field.pseudoconstant}
'pseudoconstant' => {$field.pseudoconstant|@print_array},
+{/if}
+{if $field.readonly || $field.name === $table.primaryKey.name}
+ 'readonly' => TRUE,
{/if}
'add' => {if $field.add}'{$field.add}'{else}NULL{/if},
),