Skip to main content
Topic: How to call an array in add page from controller? (Read 2117 times) previous topic - next topic

How to call an array in add page from controller?

From few days I can't figure out the following:
I want to call array in add.php!

code:
// in page event before add:
......
if(isset($_POST['update'])){
 $fields = array("doc" => $_POST['doc'],
                          "test" => "11111111111111111111111"
);
 $this->set_flash_msg(get_lang('UPDATED! '), "success");
               return   $this->redirect("docs/add");
}
.....
//in add.php
I have try so much different options in controller and add.php as: $modeldata['test']; $data = $this->view_data; request, view_data, $data['test'], I even make my own view functions and etc... and No it didn't work... due to some reasons, it clear the array and display blank: and gives Notice: Trying to access array offset … or print_r gives blank array etc...
I call the controller to display other arrays  from DB as well, that seems to be the main issue... as that calls are bellow in page, and mayby that is what clears my $post['update'] data?

Please advice, how to call this array in add page?
<?php
// I want to call it this in add.php
echo fields['doc'];
echo fields['test'];

//but how to do it?


Re: How to call an array in add page from controller?

Reply #2
@willvin
Hi,
I have a form add.php, there is few calculation have to be made and should be confirmed before real submit/inserting in a db
so I make one additional button with name='update', then in page events before add I put the code:
if(isset($_POST['update'])){
 $fields = array("doc" => $_POST['doc'],
                          "test" => "11111111111111111111111",
             "uprice" => $_POST['uprice'],
           "qty" => $_POST['qty'],
"total"=> $_POST['uprice']* $_POST['qty']
);
             return   $this->redirect("docs/add");
}
The idea is to update those values from the array in the form add.php!
How to display it in add.php?
 

Re: How to call an array in add page from controller?

Reply #3
@dobsun‍ in Page Event, the lower section you will see the variables for accessing add page form data. It called $modeldata['fieldname'].

Re: How to call an array in add page from controller?

Reply #4
@wilvin
$modeldata dosen't return in add.php...

I make work around with  set/get_cookie

thanks!

Re: How to call an array in add page from controller?

Reply #5
señores, yo tambien tengo ese mismo problema, intente hacer todos los modelos de ejemplo posible, pero fue envano, alguna solucion o consejo, para mejorar esta herramienta, por favor