making a responsive Widget (counting)

Hi,

I want to create a widget to control some values in my web UI. My usecase is complex, so I’ll only want to show the problems which I cant fix.

Lets think about a small widget: a button("+"), a text field and a button ("-").

I want a widget, that transforms the input (some number) to an output (some new number) by clicking this buttons.

So here is my view (located under components/view/counter.php):




<div>

    <?php echo CHtml::Image(CHtml::asset(Yii::getPathOfAlias('webroot.images.up').'.png', '+')); ?>

    <br>

    <?php echo CHtml::textField('counter', $this->counter); ?>

    <br>

    <?php echo CHtml::Image(CHtml::asset(Yii::getPathOfAlias('webroot.images.down').'.png', '-')); ?>

</div>



…and my controller (located under components/counter.php):




<?php

class Counter extends CWidget

{

    public $pickcount;

    private $counter;


    public function getCounter(){return $this->counter;}


    public function raiseCounter(){

        $this->counter = $this->counter + 1;

        checkConsitency();

    }

    public function lowerCounter(){

        $this->counter = $this->counter - 1;

        checkConsitency();

    }


    /**

     *

     */

    public function init()

    {

        //... some string actions, don't mind everything is good, keep it simple $pickcount is the result ...

                $this->counter =  $this->pickcount

    }




    private function checkConsitency()

    {

	//... does fancy things, don't mind everything is good...

    }




    public function run()

    {

        $this->checkConsitency();

        $this->render('counter');

        $this->pickcount = 'WOOWs to the solution: ' . $this->counter;

        //return HTML::encode($this->pickcount);

    }


}

?>



…all this is called like:




    <?php $this->widget('Counter',array('pickcount'=>$one)); ?>

    <?php $this->widget('Counter',array('pickcount'=>$two)); ?>

    <?php $this->widget('Counter',array('pickcount'=>$three)); ?>



…so how can I connect the view to the controllers raiseCounter and lowerCounter functions, rerender the view and get the values back to $one, $two and $three

Please help me or give me a hint.

Is this so wired that nobody has a hint to solve this?

Or any suggestion for a workaround?