BlueprintB
Blueprint4mo ago
5 replies
Partymann2000

Ext Admin Page Save Problem

Hi, when i change the checkbox and save it its dont save this is my code:
admin/controller.php

<?php

namespace Pterodactyl\Http\Controllers\Admin\Extensions\{identifier};

use Illuminate\View\View;
use Illuminate\View\Factory as ViewFactory;
use Pterodactyl\Http\Controllers\Controller;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
use Illuminate\Http\RedirectResponse;

use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;

class {identifier}ExtensionController extends Controller
{
  public function __construct(
    private ViewFactory $view,
    private BlueprintExtensionLibrary $blueprint,
    private ConfigRepository $config,
    private SettingsRepositoryInterface $settings,
  ) {}
  
  public function index(): View
  {

    // GET DATABASE VALUES
    $adm_servers_server_name = $this->blueprint->dbGet('{identifier}', 'adm_servers_server_name');

    // SET DEFAULT DATABASE VALUES
    $default_adm_servers_server_name = 0;


    // APPLY DEFAULT DATABASE VALUES
    if($adm_servers_server_name == "") { $this->blueprint->dbSet('{identifier}', 'adm_servers_server_name', "$default_adm_servers_server_name"); $adm_servers_server_name = $default_adm_servers_server_name; };

    return $this->view->make(
      'admin.extensions.{identifier}.index', [
        'adm_servers_server_name' => $adm_servers_server_name,

        'root' => "/admin/extensions/{identifier}",
        'blueprint' => $this->blueprint,
      ]
    );
  }
  /**
   * @throws \Pterodactyl\Exceptions\Model\DataValidationException
   * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
   */
  public function update({identifier}SettingsFormRequest $request): RedirectResponse
  {
    foreach ($request->normalize() as $key => $value) {
      $this->settings->set('{identifier}::' . $key, $value);
    }

    return redirect()->route('admin.extensions.{identifier}.index');
  }
}
class {identifier}SettingsFormRequest extends AdminFormRequest
{
  public function rules(): array
  {
    return [
        'adm_servers_server_name' => 'boolean',
    ];
  }

  public function attributes(): array
  {
    return [
        'adm_servers_server_name' => 'Server Name',
    ];
  }
}
Solution
MDN Web Docs
<input> elements of type checkbox are rendered by default as boxes that are checked (ticked) when activated, like you might see in an official government paper form. The exact appearance depends upon the operating system configuration under which the browser is running. Generally this is a square but it may have rounded corners. A checkbox allow...
<input type="checkbox"> - HTML | MDN
Was this page helpful?