KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Getting the form values from Input #1750

Open Richb201 opened this topic on on Dec 7, 2020 - 4 comments

Richb201 commented on Dec 7, 2020

I have a form that i created with Input. Here a sample of the form generated.

When the user hits the submit form button I am able to get the choices that they made from the $_POST array at indexes: Please_check_off_Business_Components_workedon , Please_check_off_Projects_workedon

But the radio buttons are being created by:

<strong>Activities - please check off activites performed by you</strong>
<?php
foreach($this->dataStore("activity") as $i=>$row) {
    echo "<div>";
    echo $row["activity"];
    \koolreport\inputs\RadioList::create([
        "name"=>"radio".$i,
        "data"=>[
            "Yes"=>1,
            "No"=>2,
            "n/a"=>0
        ],
        "display"=>"horizontal"
    ]);

And in the $_POST they appear as radio0="0" radio1="0" radio2="0"

Thus I don't know what activity radio0 refers to since each survey is different. How can i find out what activity radio2 (for example) is? Instead of using radio.$i as the index, can I use "radio".$row->["activity]?

Richb201 commented on Dec 7, 2020

I decided to use $row."#".$row["activity"] in the foreach statement above.

So now I am looking in the $_REQUEST[] to see how many items have been chosen from the Please_check_off_Business_Components_workedon group. But I am having trouble counting those. I tried $iCount= count( $_REQUEST['Please_check_off_Business_Components_workedon', COUNT_RECURSIVE ); but that does't seem to work. Any idea why?

Richb201 commented on Dec 7, 2020

I tried this in the view, but it still doesn't work:

<?php
$taxyear=$this->datastores->employees->taxyear;
TextBox::create(array("name" => "taxyear","value"=>$taxyear))
?>
Richb201 commented on Dec 7, 2020

OK. Got it working , mostly. I am using this:

TextBox::create(array("name" => "taxyear",
 "title"=>"From",
            "value"=>$this->dataStore("employees")->get(0,"taxyear"))
);
TextBox::create(array("name" => "taxyear",
 "title"=>"To:",
            "value"=>$this->dataStore("employees")->get(0,"taxyear"))
);

I'd like to have the word From and the word To appear in the form. Also, I'd like to subtract 12 months from the first taxyear date. isn't there some type of date manipulation function build in?

Richb201 commented on Dec 8, 2020

I need to get the taxyear value into a $string so I can run this code on it:

$dateString = $taxyear."01";   //need to append 01 to end of TY
$lastDateOfMonth = date("Y-m-t", strtotime($dateString));
$date=date_create($lastDateOfMonth);
date_modify($date,"-365 days");

As you can see from above, the taxyear is available in the employees dataStore. How can I get it from the dataStore to the $taxyear variable?

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None