Skip to content

Instantly share code, notes, and snippets.

@devfabriciobr
Created February 3, 2026 19:00
Show Gist options
  • Select an option

  • Save devfabriciobr/8036c2cad9201f6fd17ac2ea72bd5175 to your computer and use it in GitHub Desktop.

Select an option

Save devfabriciobr/8036c2cad9201f6fd17ac2ea72bd5175 to your computer and use it in GitHub Desktop.
ATUALIZAR TDBUniqueSearch
<?php
class FormDynamicSessionCriteriaView extends TPage
{
private $form;
function __construct()
{
parent::__construct();
$this->form = new BootstrapFormBuilder('form_hierarchical');
$this->form->setFormTitle(_t('Hierarchical combo'));
$city_id = new TDBCombo('city_id', 'samples', 'City', 'id', 'name', 'name');
$filter = new TCriteria;
$filter->add(new TFilter('city_id', '=', "'{session.city_id_filter}'"));
$customer_id = new TDBUniqueSearch('customer_id', 'samples', 'Customer', 'id', 'name', 'name', $filter);
$city_id->enableSearch();
$customer_id->setMinLength(1);
$this->form->addFields([new TLabel('City')], [$city_id]);
$this->form->addFields([new TLabel('Customer')], [$customer_id]);
$city_id->setChangeAction(new TAction(array($this, 'onCityChange')));
$vbox = new TVBox;
$vbox->style='width:100%';
$vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
$vbox->add($this->form);
parent::add($vbox);
}
public static function onCityChange($param)
{
if (!empty($param['city_id']))
{
TSession::setValue('city_id_filter', $param['city_id']);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment