Page 1 of 1

readonly or visible field master detail on input page

Posted: Sat Jun 22, 2024 3:52 pm
by lissa

hi,
i have a detail master page,
I want a readonly field when adding or editing data in the details section,
usually I use this code it works

$this-><fields>->ReadOnly = true;
$this-><fields>->Visible = false;

when I try it doesn't work?
is there any change? but in my old project the code worked?
I tried on one of add/copy page - page_render and tried also on page_datarendering not working


Re: readonly or visible field master detail on input page

Posted: Sun Jun 23, 2024 12:06 am
by mobhar

You may try Page_Load server event that belongs to the List Page of your detail table.


Re: readonly or visible field master detail on input page

Posted: Sun Jun 23, 2024 6:54 am
by lissa

still not working, this field is type select and select multiple.
is there a solution for select


Re: readonly or visible field master detail on input page

Posted: Sun Jun 23, 2024 6:45 pm
by lissa

Solved
$this->FIELDS->EditAttrs["disabled"] = "disabled";
but I found a new problem when using this code,
when editing data and saving, the field that I disabled becomes null in the database,


Re: readonly or visible field master detail on input page

Posted: Sun Jun 23, 2024 9:57 pm
by mobhar

You may simply put this following code in Row_Updating server event:

$rsnew["FIELDS"] = $rsold["FIELDS"];

Re: readonly or visible field master detail on input page

Posted: Mon Jun 24, 2024 12:27 pm
by lissa

Yes, I know how to use this code, but if the user wants to edit the value it can't be changed, is there a solution?


Re: readonly or visible field master detail on input page

Posted: Mon Jun 24, 2024 12:35 pm
by mobhar

Are you sure? Since in your earlier posts, you obviously want to disable that field. If the field is disabled in Edit Page, then the value cannot be changed by your end-users.


Re: readonly or visible field master detail on input page

Posted: Mon Jun 24, 2024 12:40 pm
by lissa

Yes, the disabled value is only for users, not for administrators.
if the administrator changes the data the value becomes null
and if the user updates the enabled field value data, the disabled value also changes to null
I separate admin and user using code
if (!IsAdmin()) { .... }


Re: readonly or visible field master detail on input page

Posted: Mon Jun 24, 2024 1:04 pm
by mobhar

Then you may separate the code, too in Row_Updating server event for user admin and non-admin.


Re: readonly or visible field master detail on input page

Posted: Mon Jun 24, 2024 1:14 pm
by lissa

thank you