inline/grid, edit/add field suppression

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

inline/grid, edit/add field suppression

Post by fbachofner »

I have a couple simple tables where it would be nice to enable adding/editing inline or in a grid ONLY (i.e. no add page or edit page)

I have my typical 4 "tracking" fields:
Record_Last_Modified (timestamp)
Record_Modified_By (int)
Record_Added (timestamp)
Record_Added_By (int)

These need to be checked in the List View. Unfortunately, this makes the fields appear as editable in inline/grid add/edit modes.

What is the best way to suppress these fields in these modes (i.e. inline/grid add/edit modes)? [They get filled automatically and I do not want to tempt a user to do something they can not override.]

Custom code? If so, where? [There is not a "grid" or "inline" page in the Table-Specific custom code branch, so it probably has to do with Add or Edit pages and some conditional logic.]

Or is there a way to do this more simply with field setup?

Thanks!


mobhar
User
Posts: 11747

Post by mobhar »

You may unchecked those 4 fields from "Fields" setup under the "List" column, afterwards, write your code to update those fields, either in "Row_Inserting" for add process or "Row_Updating" for edit/update process.


Webmaster
User
Posts: 9430

Post by Webmaster »

Set up [Auto-Update Value] for those fields.


fbachofner
User
Posts: 70

Post by fbachofner »

Hi mobhar:

mobhar wrote:
You may unchecked those 4 fields from "Fields" setup under the
"List" column

No, then they would NOT show up on the List page, which is one of the requirements . . .


fbachofner
User
Posts: 70

Post by fbachofner »

Webmaster wrote:
Set up [Auto-Update Value] for those fields.

OK, that makes sense.

Question: two of the fields are timestamps which are already automatically updated by triggers in the database, so those fields don't actually need an [Auto-Update Value] from PHPMaker.

I do understand that setting [Auto-Update Value] would hide the field in inline and grid modes, but it might confuse me or anyone else working with the application in PHPMaker at some point in the future.

Is there another way to hide the fields in inline and grid modes? Maybe some custom code? [I think one benefit of custom code is that it can easily be documented with // remarks.]

Thanks for your help.


danielc
User
Posts: 1601

Post by danielc »

Add this code in Page_Load server event for your List Page:
// check for grid edit/grid add/inline edit/inline add
if ($this->CurrentAction == "gridedit" $this->CurrentAction == "gridadd" $this->CurrentAction == "edit" || $this->CurrentAction =="add")
$this->YourField->Visible = FALSE;


Webmaster
User
Posts: 9430

Post by Webmaster »

Or:

$this->YourField->Visible = !$this->IsAddOrEdit();


Post Reply