---
title: HelperOptions — pagina de configuracion global
section: admin
slug: helperoptions
description: Como usar HelperOptions en PrestaShop para crear paginas de configuracion global del Back Office con fields_options, grupos de campos y guardado automatico.
keywords: prestashop helperoptions configuracion back office fields_options admin modulo guardado
last_updated: 2024-12-01
source_url: "https://ayudaprestashop.es/admin/helperoptions"
---

# HelperOptions — pagina de configuracion global

> Como usar HelperOptions en PrestaShop para crear paginas de configuracion global del Back Office con fields_options, grupos de campos y guardado automatico.

`HelperOptions` es una variante de HelperForm orientada a paginas de configuracion de AdminControllers del core (como AdminGeneralController). Genera bloques de opciones con guardado automatico en `Configuration` o propiedades del objeto.

## HelperOptions vs HelperForm

| Caracteristica | HelperForm | HelperOptions |
| --- | --- | --- |
| Uso tipico | CRUD de entidades | Configuracion global |
| Estructura | fields_form[] | fields_options[] |
| Guardado | Manual en postProcess() | Automatico en AdminController |
| Agrupacion visual | Paneles (legend) | Tabs o paneles |
| Auto-populate | fields_value | Lee Configuration directamente |

## Estructura fields_options

*Estructura basica de fields_options*

```php
<?php

// En un AdminController (extends AdminController)
public function __construct()
{
    $this->table        = 'configuration';
    $this->identifier   = 'id_configuration';
    $this->className    = 'Configuration';
    $this->bootstrap    = true;
    $this->fields_options = [
        // ── GRUPO 1 ──
        'general' => [
            'title'  => $this->l('Configuracion General'),
            'icon'   => 'icon-cogs',
            'fields' => [
                'MY_MODULE_API_KEY' => [
                    'title'      => $this->l('API Key'),
                    'hint'       => $this->l('Clave de API del proveedor'),
                    'type'       => 'text',
                    'size'       => 60,
                    'required'   => true,
                    'class'      => 'fixed-width-xxl',
                    'validation' => 'isGenericName',
                ],
                'MY_MODULE_ACTIVE' => [
                    'title'      => $this->l('Activar servicio'),
                    'type'       => 'bool',
                    'required'   => false,
                ],
            ],
            'submit' => ['title' => $this->l('Guardar')],
        ],
        // ── GRUPO 2 ──
        'advanced' => [
            'title'  => $this->l('Opciones Avanzadas'),
            'icon'   => 'icon-wrench',
            'fields' => [
                'MY_MODULE_MODE' => [
                    'title'      => $this->l('Modo de operacion'),
                    'type'       => 'select',
                    'list'       => [
                        ['id' => 'sandbox',    'name' => 'Sandbox (Pruebas)'],
                        ['id' => 'production', 'name' => 'Produccion'],
                    ],
                    'identifier' => 'id',
                    'validation' => 'isCleanHtml',
                ],
                'MY_MODULE_TIMEOUT' => [
                    'title'      => $this->l('Timeout (segundos)'),
                    'type'       => 'text',
                    'size'       => 5,
                    'validation' => 'isUnsignedInt',
                    'cast'       => 'intval',
                ],
            ],
            'submit' => ['title' => $this->l('Guardar opciones avanzadas')],
        ],
    ];

    parent::__construct();
}
```

## Tipos de campos

| Tipo | Descripcion | Atributos especiales |
| --- | --- | --- |
| text | Campo de texto | size, class, prefix, suffix, required |
| bool | Toggle si/no | - |
| select | Lista desplegable | list (array), identifier |
| textarea | Texto multilínea | cols, rows |
| color | Selector de color | - |
| file | Subida de archivo | display_image |
| password | Contraseña | - |
| checkbox | Casilla multiple | values (array) |
| radio | Botones de radio | values (array) |
| image | Mostrar imagen actual | name, dir |
| thumbnails | Galeria de thumbnails | files, name |

## Procesar y guardar

*Procesar el submit en postProcess() del AdminController*

```php
<?php

// En el AdminController
public function postProcess(): void
{
    // HelperOptions genera un submit_btn con nombre 'submitOptions{tabla}'
    // Para tabla='configuration', es 'submitOptionsconfiguration'
    if (Tools::isSubmit('submitOptionsconfiguration')) {
        // Iterar los grupos y campos para guardar
        foreach ($this->fields_options as $group) {
            foreach ($group['fields'] as $key => $field) {
                $value = Tools::getValue($key);

                // Aplicar cast si existe
                if (isset($field['cast'])) {
                    $value = $field['cast']($value);
                }

                // Validar si existe
                if (isset($field['validation'])) {
                    $method = $field['validation'];
                    if (!Validate::$method($value)) {
                        $this->errors[] = $this->l('Valor invalido para: ') . $field['title'];
                        continue;
                    }
                }

                Configuration::updateValue($key, $value);
            }
        }

        if (empty($this->errors)) {
            $this->confirmations[] = $this->l('Configuracion guardada correctamente.');
        }
    }

    parent::postProcess();
}
```


---

*Fuente: [https://ayudaprestashop.es/admin/helperoptions](https://ayudaprestashop.es/admin/helperoptions). Version Markdown generada automaticamente para consumo por LLMs.*
