Jump to content

Question

Posted

another time is me :)

i'm creating a module for cpanel manage2 , i have almost all done now, but i have something wrong with my code in getPackageFields(), i want to pass the outpot of array (packages) to an select box . my array is :
 

Array (
    [@attributes] => Array (
        [reason] => OK
        [status] => 1
        [version] => 0.3 )
    [packages] => Array (
        [@attributes] => Array (
            [Pxxx7] => THREE-YEAR
            [Pxxx8] => ONE-YEAR
            [Pxxx6] => FREE-ONE-YEAR-ENKOMPASS
            [Pxxx4] => TWO-YEAR
            [Pxx61] => ONE-YEAR-VPS
            [Pxx46] => xxxx-INTERNAL
            [Pxx50] => xxxx-INTERNAL-VPS
            [Pxx90] => xxxx-CLOUDLINUX-INTERNAL-WITH-CPANEL
            [Pxx94] => xxxx-CLOUDLINUX-INTERNAL-WITHOUT-CPANEL
        )
    )
)



what wrong in my code ?

 

    public function getPackageFields($vars=null) {
        Loader::loadHelpers($this, array("Html"));
        $module_row = $this->getModuleRow();
        $fields = new ModuleFields();
        
           
        $types = $this->getLicenseTypes($module_row)  ;
        $license_type = $fields->label(Language::_("CpanelManagetwo.package_fields.license_type", true), "license_type");
        $license_type->attach($fields->fieldSelect("meta[license_type]", $types['packages']['@attributes'],
            $this->Html->ifSet($vars->meta['license_type']), array('id'=>"license_type")));
        $fields->setField($license_type);

        return $fields;
    }

4 answers to this question

Recommended Posts

  • 0
Posted

GOT IT , the full code for reference :

    public function getPackageFields($vars=null) {
        Loader::loadHelpers($this, array("Html"));
        // $module_row = $this->getModuleRow($vars->module_row);
        $fields = new ModuleFields();
            
        // Fetch all packages available for the given server or server group
        $module_row = null;
        if (isset($vars->module_group) && $vars->module_group == "") {
            if (isset($vars->module_row) && $vars->module_row > 0) {
                $module_row = $this->getModuleRow($vars->module_row);
            }
            else {
                $rows = $this->getModuleRows();
                if (isset($rows[0]))
                    $module_row = $rows[0];
                unset($rows);
            }
        }
        else {
            // Fetch the 1st server from the list of servers in the selected group
            $rows = $this->getModuleRows($vars->module_group);

            if (isset($rows[0]))
                $module_row = $rows[0];
            unset($rows);
        }            
            
        if ($module_row) {
            $types = $this->getLicenseTypes($module_row)  ;
        }            
                    
        $license_type = $fields->label(Language::_("CpanelManagetwo.package_fields.license_type", true), "license_type");
        $license_type->attach($fields->fieldSelect("meta[license_type]", $this->Html->ifSet($types['packages']['@attributes'])  ,
            $this->Html->ifSet($vars->meta['license_type']), array('id'=>"license_type")));
        $fields->setField($license_type);

        return $fields;
    }
  • 0
Posted

i think i have get the probleme

$module_row = $this->getModuleRow();
$module_row = $this->getModuleRow($vars->module_row);

is not returning any data ?

 

how to get the getModuleRow inside the getPackageFields() function ?

  • 0
Posted
  On 7/29/2014 at 4:47 PM, naja7host said:

i think i have get the probleme

$module_row = $this->getModuleRow();
$module_row = $this->getModuleRow($vars->module_row);

is not returning any data ?

 

how to get the getModuleRow inside the getPackageFields() function ?

 

The module row may not yet be known when selecting package fields. Most modules that need it will default to the first module row, similar to how the cPanel module currently works.

 

 

  On 7/29/2014 at 4:40 PM, naja7host said:

 

another time is me :)

i'm creating a module for cpanel manage2 , i have almost all done now, but i have something wrong with my code in getPackageFields(), i want to pass the outpot of array (packages) to an select box . my array is :

 

Array (
    [@attributes] => Array (
        [reason] => OK
        [status] => 1
        [version] => 0.3 )
    [packages] => Array (
        [@attributes] => Array (
            [Pxxx7] => THREE-YEAR
            [Pxxx8] => ONE-YEAR
            [Pxxx6] => FREE-ONE-YEAR-ENKOMPASS
            [Pxxx4] => TWO-YEAR
            [Pxx61] => ONE-YEAR-VPS
            [Pxx46] => xxxx-INTERNAL
            [Pxx50] => xxxx-INTERNAL-VPS
            [Pxx90] => xxxx-CLOUDLINUX-INTERNAL-WITH-CPANEL
            [Pxx94] => xxxx-CLOUDLINUX-INTERNAL-WITHOUT-CPANEL
        )
    )
)

what wrong in my code ?

 

    public function getPackageFields($vars=null) {
        Loader::loadHelpers($this, array("Html"));
        $module_row = $this->getModuleRow();
        $fields = new ModuleFields();
        
           
        $types = $this->getLicenseTypes($module_row)  ;
        $license_type = $fields->label(Language::_("CpanelManagetwo.package_fields.license_type", true), "license_type");
        $license_type->attach($fields->fieldSelect("meta[license_type]", $types['packages']['@attributes'],
            $this->Html->ifSet($vars->meta['license_type']), array('id'=>"license_type")));
        $fields->setField($license_type);

        return $fields;
    }

 

What is the output? $types['packages']['@attributes'] should be fine as long as that is an array of key/value pairs.

  • 0
Posted

the probleme is not the code , the probleme is from the getModuleRow()

 

this one is also not working

        // Fetch all packages available for the given server or server group
        $module_row = null;
        if (isset($vars->module_group) && $vars->module_group == "") {
            if (isset($vars->module_row) && $vars->module_row > 0) {
                $module_row = $this->getModuleRow($vars->module_row);
            }
            else {
                $rows = $this->getModuleRows();
                if (isset($rows[0]))
                    $module_row = $rows[0];
                unset($rows);
            }
        }
        else {
            // Fetch the 1st server from the list of servers in the selected group
            $rows = $this->getModuleRows($vars->module_group);

            if (isset($rows[0]))
                $module_row = $rows[0];
            unset($rows);
        }            
            
            
        $types = $this->getLicenseTypes($module_row)  ;

i have tried the same code as cpanel but is not working , how i can see the output of the getModuleRow() ?

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...