Developer Center

Adding Extra Field to Admin Area

To add extra fields to the service detail in the Administrator panel, you must follow the steps below.

Adding Fields

In the class, you must create a function with adminArea_service_fields name.

The return value must be an array, you can use the parameters which you used in config_options function for this function too.

public function adminArea_service_fields(){
    $c_info                 = $this->options["creation_info"];
    $field1                 = isset($c_info["field1"]) ? $c_info["field1"] : NULL;
    $field2                 = isset($c_info["field2"]) ? $c_info["field2"] : NULL;

    return [
        'field1'                => [
            'wrap_width'        => 100,
            'name'              => "Field 1",
            'description'       => "Field 1 Description",
            'type'              => "text",
            'value'             => $field1,
            'placeholder'       => "sample placeholder",
        ],
        'field2'                => [
            'wrap_width'        => 100,
            'name'              => "Field 2",
            'type'              => "output",
            'value'             => '<input name="creation_info[field2]" type="text" value="'.$field2.'" />',
        ],
    ];
}
Saving Fields

In the class, you must create a function with save_adminArea_service_fields name.

The return value must be an array, it sends the form data obtained after clicking the update button in service detail in the received parameter in the function, the received parameter has 2 indexes, [creation_info] and [config].

public function save_adminArea_service_fields($data=[]){

    /* OLD DATA */
    $o_c_info           = $data['old']['creation_info'];
    $o_config           = $data['old']['config'];
    $o_ftp_info         = $data['old']['ftp_info'];
    $o_options          = $data['old']['options'];

    /* NEW DATA */

    $n_c_info           = $data['new']['creation_info'];
    $n_config           = $data['new']['config'];
    $n_ftp_info         = $data['new']['ftp_info'];
    $n_options          = $data['new']['options'];

    if($n_c_info['field1'] == '')
    {
        $this->error = 'Do not leave Field 1 empty.';
        return false;
    }

    if($o_options['disk_limit'] != $n_options['disk_limit'])
    {
        /* Example: Change Disk Limit
        if(!$this->change_disk_quota($n_options["disk_limit"])) return false;
        */
    }

    return [
        'creation_info'     => $n_c_info,
        'config'            => $n_config,
        'ftp_info'          => $n_ftp_info,
        'options'           => $n_options,
    ];
}
 
Multi-Purpose Client Area Buttons Multi-Purpose Admin Area Buttons

Do you have any questions?

Feel free to contact us
Contact Us
Copyright © 2024. All Rights Reserved.
Join Our Discord Channel
Top