Read-only fields in the user profile widget

Peter Bishop
Kilo Expert

I'd like to change some of the fields in the user profile widget to read-only while retaining the look-and-feel of the output. I've cloned the OOB user_profile widget and made the following change:

<div ng-repeat="fieldModel in getSysUserModelFields()">
  <div class="list-group-item">
    <div>
      <sp-editable-field block="true" table="sys_user" editable-by-user="false" table-id="data.sysUserID" field-model="fieldModel"></sp-editable-field>
    </div>
  </div>
</div>

which works fine in that the fields can no longer be changed. However where a field has no data entered I don't get the header. For example when editable I get:

find_real_file.png

but when read-only I get:

find_real_file.png

Is there a way to display headers for all of the fields returned by getSysUserModelFields(), even if the option to edit them is set to false?

Also is there a way to selectively make a field read-only? For example you change change your phone number but not your email address?

Thanks.

6 REPLIES 6

Hi @ibhavya,

Let's say you want to set sys_user.location as ReadOnly for end users, ie without Write rights.
Set write ACL on this field, with required roles or conditions who should be allowed to write.

It'll exclude write access on this field for users without these roles. And also, the sp-editable-field for this field in the user_profile Widget will return 'false' for those users.

Don't forget to keep access for allowed operators.

 

Peter Bishop
Kilo Expert

Ended up going a slightly different way which solved both the optional editing and the header display for empty fields:

<strong class="pad-right">{{ fieldModel.label }}</strong><br />
<span ng-if="fieldModel.name == 'email'"><sp-editable-field block="false" table="sys_user" editable-by-user="false" table-id="data.sysUserID" field-model="fieldModel"></sp-editable-field></span>
<span ng-if="fieldModel.name != 'email'"><sp-editable-field block="false" table="sys_user" editable-by-user="data.isLoggedInUsersProfile" table-id="data.sysUserID" field-model="fieldModel"></sp-editable-field></span>