Manipulate Value While Inputing Data

Paramita Daniswari
2 min readJun 27, 2023

--

PHPMaker Tutorial Series

Hi All, welcome to PHPMaker tutorial series !

Sometimes we need to change or manipulate value of input or update field while adding the data to database. For example, when add new user, we want the default username is <nrp> and the password is <nrp>_pass. We can not use autofill feature from lookUp table because master table only contain name and nrp(id user), so we have to modify the nrp in row_inserting() function to become the default password. Let’s start it !

  1. Take a look at The Master Table

we have master table called master_users. This table will become the reference while adding new user using lookup features.

  1. Take a look at the input form

Here’s the input form. We will make automatic password using default format while adding new user.

2. Open the code server and find row_inserting() function

Define the variable. $rsold means the old value of field and $rsnew means the new value of field. Old value for password field is null and new value is text we want to add. Because the new value of password is concatenated nrp and “_pass” so we write :

 $rsnew['password']=$rsnew['nrp']."_pass";

3. Generate it and try it out

It’s Done! pretty simple right

--

--

Paramita Daniswari
Paramita Daniswari

Written by Paramita Daniswari

Programming Enthusiast - The written words yearn for timeless wings

No responses yet