ViewValue cannot be set for edit page

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

ViewValue cannot be set for edit page

Post by nyukuri »

Hello,

I am trying to change the ViewValue ( $this->field->ViewValue = "..."; ) but that works only for the ViewPage and ListPage.
I need to show this value also on the EditPage. I have set that field to ReadOnly, so there is no input field. The ViewValue still cannot be set/defined. Is there a workaround?
Thank you!

Martin


Webmaster
User
Posts: 9425

Post by Webmaster »

For add/edit page, use: $this-><field>->EditValue


kirondedshem
User
Posts: 642

Post by kirondedshem »

As long as you want to make a vlue readonly on edit field, if you still want it to be included in update query, then DONT TICK readonly in field settings as this will ensure it wont be included in update query, so instead set readonly property at runtime which applies it on the interface only. But if you just want to set it for presentation purposes only any your not interested in updating its value when you save, then you can use the field settings readonly. use EditValue while one ADD and Edit forms.
For example I auto fill the amount payable like this
// Page Data Rendering event
function Page_DataRendering(&$header) {
// Example:
//$header = "your header";
//determine value to auto fill
$amount_due = 200;
//assign only for first time ie dont assign if already assigned once before
if($this->amount_payable->EditValue == '')
{
$this->amount_payable->EditValue = $amount_due;
}

}

And if users are not allowed to change this value you can set readonly in page load such that users cant change it.
// Page Load event
function Page_Load() {
//echo "Page Load";
$this->amount_payable->ReadOnly = TRUE;
}


Post Reply