Qfom::Form_PreRender() as an alternative to open/close call back methods in drafts/panels generated

Login or register to post comments
No replies
Offline
Joined: 12/03/2009

As Form_PreRender() is executed as soon as the form has been posted an event triggered, it can act as a global switcher for qcubed ajax form, just with an « action » (Edit | List values) , a « className » and a « intPK » qform'sproperties (in the following sample the 'ParamsControler') and defined from the edit and list classes of the drafts/panels directory by the $this->objForm property, then here is a Qfom::Form_PreRender() sample :

function Form_PreRender() {
        $className = sprintf('Admin%s%sPanel',
                $this->ParamsControler->ClassName,
                 $this->ParamsControler->Action);
        switch (strtoupper($this->ParamsControler->Action)){           
            case 'LIST':
                $this->pnlLeft->RemoveChildControls(true);
new $className($this->pnlLeft);                           
                break;
             case 'EDIT' :
                 $this->pnlRight->RemoveChildControls(true);
                 new $className($this->pnlRight,
                                $this->ParamsControler->PK ,null);
                 $this->pnlRight->Visible = true;
                break;
            case 'CLOSE' :
                $this->pnlRight->RemoveChildControls(true);
                $this->pnlRight->Visible = false;
                if ($this->ParamsControler->IsChanged) 
                    $this->pnlLeft->Refresh();
                break;
            default:
        }

The default case is important to catch all events (as an upload) not concerned by the "route".
It's even better to hard code that by codegen/templates.
I think this more simple than the CloseEditPane and SetEditPane callback methods passed as parameters to the qpanels classes.
Do you feel that safe, a good idea or did I misunderstood something ?