ReadOnly Field in Form
PHPMaker Tutorial Series
Hi All, welcome to PHPMaker tutorial series.
Transactional website commonly have CRUD features. CRUD stands for Create, Read, Update and Delete. We need to define form input to add data to database in order to make Create function works well.
Sometimes we need Read only field that usually filled by another system. For the example filed city that depends on province. This city filed should’nt freely edit by user, thus we make this field ReadOnly.
In PHPMaker we can implement this feature with these steps :
- Click our target table then Click the Server Event Tab and menu rendered
2. Copy Paste the file and edit as needed
function Row_Rendered()
{
// To view properties of field class, use:
//var_dump($this-><FieldName>);
$this-><yourFieldName>->ReadOnly = TRUE;
}
In this case i want make my field “nama versi akademik” to become ReadOnly. So my Code looks like this
function Row_Rendered()
{
// To view properties of field class, use:
//var_dump($this-><FieldName>);
$this->nama_versi_akademik->ReadOnly = TRUE;
}
Make sure your field name match with the column name
3. Generate the project and try it out
The result should looks like this. The Gray field indicates the field can only be read. User can not freely edit this field.
So easy, right? Hope it helps !