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.

ViewValue cannot be set for edit page

Postby nyukuri » Sat Jan 13, 2018 5:53 pm

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
nyukuri
 
Posts: 123
Joined: Mon Nov 10, 2014 3:13 pm

Re: ViewValue cannot be set for edit page

Postby Webmaster » Mon Jan 15, 2018 9:49 am

For add/edit page, use: $this-><field>->EditValue
Webmaster
 
Posts: 10734
Joined: Fri Aug 06, 2004 5:59 pm

Re: ViewValue cannot be set for edit page

Postby kirondedshem » Mon Jan 15, 2018 1:49 pm

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;
}
kirondedshem
 
Posts: 330
Joined: Sat Jan 28, 2017 7:13 pm


Return to General Discussion (PHPMaker)