KoolReport's Forum

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

Why won't the textboxes get populated with the default values? #1748

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

Richb201 commented on Dec 4, 2020

I have used your example and managed to get the $email and $campaign from one of the tables.

        $data = $this->dataStore("employees")->data();
         $email=$data[0]['email'];
        $campaign=$data[0]['campaign'];

Now, besides using these values when building the datastores for use in the view, I also need them in text boxes in the view(actually, I need to make two of them invisible). Here is how I am setting up the ParamValues

protected function defaultParamValues()
{
    return array(
        "dateRange"=>array('2017-07-01','2017-07-31'),
        "campaign"=>$campaign,
        "taxyear"=>$taxyear,
        "admin_email"=>$email,
        "select"=>"",
        "multiSelect"=>array(),
        "radioList"=>"",
        "checkBoxList"=>array(),
        "startDatePicker"=>date("Y-m-d 00:00:00"),
        "endDatePicker"=>date("Y-m-d 23:59:59"),
        "rangeSliderOne"=>array(50),
        "rangeSliderTwo"=>array(20,80),
    );
}

In the view I have put :

   <?php TextBox::create(array("name"=>"campaign")) ?>
    <?php TextBox::create(array("name"=>"taxyear")) ?>
    <?php TextBox::create(array("name"=>"admin_email")) ?>

The boxes appear but they are blank. What am I doing wrong?

KoolReport commented on Dec 5, 2020

Could you please check if there are parameters and input binding.

Richb201 commented on Dec 5, 2020

I have these: protected function defaultParamValues()

{
    return array(
        "dateRange"=>array('2017-07-01','2017-07-31'),
        "campaign"=>$campaign,
        "taxyear"=>$taxyear,
        "admin_email"=>$email,
        "select"=>"",
        "multiSelect"=>array(),
        "radioList"=>"",
        "checkBoxList"=>array(),
        "startDatePicker"=>date("Y-m-d 00:00:00"),
        "endDatePicker"=>date("Y-m-d 23:59:59"),
        "rangeSliderOne"=>array(50),
        "rangeSliderTwo"=>array(20,80),
    );
}
protected function bindParamsToInputs()
{
    return array(
        "campaign"=>$campaign,
        "taxyear"=>$taxyear,
        "admin_email"=>$email,
        "dateRange",
        "select",
        "multiSelect",
        "textBox",
        "radioList",
        "checkBoxList",
        "startDatePicker",
        "endDatePicker",
        "singleSelect2",
        "multipleSelect2",
        "singleBSelect",
        "multipleBSelect",
        "rangeSliderOne",
        "rangeSliderTwo",
    );
}
KoolReport commented on Dec 6, 2020

I see the reason. You should do:

protected function bindParamsToInputs()
{
    return array(
        "campaign",
        "taxyear",
        "admin_email",
        "dateRange",
        "select",
        "multiSelect",
        "textBox",
        "radioList",
        "checkBoxList",
        "startDatePicker",
        "endDatePicker",
        "singleSelect2",
        "multipleSelect2",
        "singleBSelect",
        "multipleBSelect",
        "rangeSliderOne",
        "rangeSliderTwo",
    );
}

This function provide the mapping between param name and input name. This is the short hand form for example instead of "campaign"=>"campaign" we only write "campaign".

Richb201 commented on Dec 6, 2020

I made the change but the fields still appear to not getting populated. When I get back to my office I'll check it out with the debugger to make sure it is not my code that is not working. Basically I am trying to get some data from the form into the form.view. Do you have a better way to do that?

Richb201 commented on Dec 6, 2020

got it working. thx

KoolReport commented on Dec 6, 2020

Awesome :)

KoolReport commented on Dec 6, 2020

Awesome :)

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
solved

None