KoolReport's Forum

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

Integer spinner as input element, passing the value to sql #739

Closed iRiyada opened this topic on on Mar 13, 2019 - 4 comments

iRiyada commented on Mar 13, 2019

report.view.php

<input id="inactive" type="number" value="5" min="1" max="1000" step="1"/>
<button type="submit" class="btn btn-success"><i class="fa fa-search"></i></button>

I want to use that input value to make a comparison in query. For example:

 use \koolreport\inputs\Bindable;
    use \koolreport\inputs\POSTBinding;
    
    protected function defaultParamValues()
    {
        return array(
            "inactive"=>5,
            
        );
    
    }
    protected function bindParamsToInputs()
    {
        return array(
            "inactive",
            
        );
    }
-..........................
 -  .......................... 
function setup()
{
SELECT .........and(           (
                u.dt_last_login is null
                or
                datediff(curdate(), u.dt_last_login) > :days)// :days is the input read
                    order by inactive_days desc, s.code")->params(array( ":days"=>$this->params["inactive"],))
            ->pipe($this->dataStore('user_details'));

:days does'nt get the input value. I tried var_dump($_post). It is returning an empty array. $this->params["inactive"]=5, which is the value initiallised.What could be wrong?

KoolReport commented on Mar 13, 2019

You just miss the name of input only to make it work.

<input id="inactive" name="inactive" type="number" value="5" min="1" max="1000" step="1"/>

with name, the input in form will post its value to server.

KoolReport commented on Mar 13, 2019

And by the way, please add the value for the input, the full version will be:

<input id="inactive" name="inactive" type="number" value="<?php echo $this->params["inactive"]; ?>" min="1" max="1000" step="1"/>
iRiyada commented on Mar 15, 2019

Thank you. It is working.

KoolReport commented on Mar 15, 2019

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