Fill a field on add page using urlencode

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

Fill a field on add page using urlencode

Post by Laim71 »

Hi,
I’ve a list page from which I want to fill a field on another form by clicking a list option link.
Below the 02 lines of code I put In ListOptions_Rendered() of the current list page.
The field to fil is “NDI”
$ndi=urlencode($this->NDI->ViewValue = $this->NDI->CurrentValue);
$this->ListOptions->Items["MAJ"]->Body = "<a href='t_modetatdiadd.php?NDI=".$ndi."'><b>Mettre à jour l’état</b></a>";

THANKS for your help


Laim71
User
Posts: 75

Post by Laim71 »

Hi,

I’d like, from a list of based on a view, to be able run some tasks about persons.
I thus used ListOptions fonctions.

This is an example of how options are defined in ListOptions_Load() of the list page.

function ListOptions_Load() {
$this->ListOptions->Add("MEM");
$this->ListOptions->Items["MEM"]->OnLeft = TRUE;

$this->ListOptions->Items["MEM"]->Header = "Faire une observation";

And below, the 02 cases I want to run

function ListOptions_Rendered() {
$mat= Urlencode($this->Matricule->CurrentValue);
$nom= Urlencode($this->Nom->CurrentValue);
Case1 : $this->ListOptions->Items["MEM"]->Body = "<a href='t_memosuiviperfadd.php?MatAgent= " . $mat . "&NomAgent= " . $nom . " '>Faire une observation</a>";

Case 2 : $this->ListOptions->Items["CFOBJ"]->Body = "<a href='t_ficheobjsagentadd.php?showdetail=t_objsagent, MatAgent= " . $mat . " '>Créer la fiche d’objectifs</a>";

For the first case, only the second field NomAgent is filled.
For the 2e case, nothing happenes.

THANKS in advance for your help.


kirondedshem
User
Posts: 642

Post by kirondedshem »

to fill a field on another form by clicking a list option link
Assuming your e using code below to let user go to add page
$ndi=urlencode($this->NDI->ViewValue = $this->NDI->CurrentValue);
$this->ListOptions->Items["MAJ"]->Body = "<a href='t_modetatdiadd.php?NDI=".$ndi."'><b>Mettre à jour l’état</b></a>";

Basic solution(not recomened for you case):
To initialise a filed on an add page with apredefined value:
go to t_modetatdi table ->select field settings->select filed you want to assign value to->scroll to the left untill you find Add section->paste your desired phpcode to generate the value in "Default Add" ie paste $_GET["NDI"]. THis should be a valid php expression read about default add in help

Recomended approach(as it has required validation):

BUT since ssometimes the add from needs to reload itself maybe incase it wants to display a validation error (which usually removes all url parameters), it is wise you first check if there exists a vlue in get parameter before you use $_GET["NDI"]. So I recomend to paste your code in page_data_rendering like:

go to t_modetatdi table-> server and cient scripts->add page->Page_DataRendering
// Page Data Rendering event
function Page_DataRendering(&$header) {

	// Example:
	//$header = "your header";
	
	//check if you have a vlue in get parameter
	if(isset($_GET["NDI"]))
	{
		//assign only for first time you dont want to overide it incase the user has lareday done something with it
		if($this->NDI->EditValue == '')
		{
		$this->NDI->EditValue = $_GET["NDI"];
		}
	}
	

}

Laim71
User
Posts: 75

Post by Laim71 »

Hi to all,
THANKS kirondedshem for your last help. I was testing all the possibilities on what you suggested me. Unfortunately I didn’t succeed yet.
When I try the solution above you suggest me, I effectively get a button but not in the place I expect. Secondly, clicking on that doesn’t fill the fields on the add page.
So I re-explain my concern.
My page is a view that lists colleagues appraised by their N+1.
I’d like for each row (colleaugue) some actions like create a goal list, create a note on his performance … must be made.
Thus, I’d like for each action that the name and a professional ID called “MatAgent” are retrieved and automatically filled in the add page on which the link is redirected.

I put this code in ListOptions_Load of my list page (No problem)

$this->ListOptions->Add("MEM");
$this->ListOptions->Items["MEM"]->OnLeft = TRUE;

$this->ListOptions->Items["MEM"]->Header = "Faire une observation";

And this one in ListOptions_Rendered of my list page

$mat = Urlencode($this->Matricule->CurrentValue);
$nom = Urlencode($this->Nom->CurrentValue);
$this->ListOptions->Items["MEM"]->Body = "<a href='t_memosuiviperfadd.php?MatAgent=" . $mat . "& NomAgent=" . $nom . " '>Faire une observation</a>";

THANKS to my SAVIOR .


Post Reply