readonly or visible field master detail on input page

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
lissa
User
Posts: 49

readonly or visible field master detail on input page

Post 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


mobhar
User
Posts: 11842

Post by mobhar »

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


lissa
User
Posts: 49

Post by lissa »

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


lissa
User
Posts: 49

Post 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,


mobhar
User
Posts: 11842

Post by mobhar »

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

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

lissa
User
Posts: 49

Post 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?


mobhar
User
Posts: 11842

Post 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.


lissa
User
Posts: 49

Post 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()) { .... }


mobhar
User
Posts: 11842

Post by mobhar »

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


lissa
User
Posts: 49

Post by lissa »

thank you


Post Reply