Page 1 of 1

ViewValue cannot be set for edit page

Posted: Sat Jan 13, 2018 5:53 pm
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


Re: ViewValue cannot be set for edit page

Posted: Mon Jan 15, 2018 9:49 am
by Webmaster

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


Re: ViewValue cannot be set for edit page

Posted: Mon Jan 15, 2018 1:49 pm
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;
}