-
-
Save devfabriciobr/8036c2cad9201f6fd17ac2ea72bd5175 to your computer and use it in GitHub Desktop.
ATUALIZAR TDBUniqueSearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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