custom('regions', _t('@banners', 'Region'))->getCustom()
->onView(function($view, $field) use ($form){
/** @var bff\tpl\admin\form\Custom $field */
$name = $field->name();
$data = $form->_data();
$regions = isset($data[$name]) ? $data[$name] : [];
$showCountry = Geo::coveringType(Geo::COVERING_COUNTRIES);
if ($showCountry) {
$countries = [];
$t = Geo::countriesList();
foreach($t as $v){
$countries[ $v['id'] ] = array('id' => $v['id'], 'title' => $v['title']);
}
}
?>
= Geo::regionSelect(0, $name, [
'on_change' => 'function(id, title, ex){ if (jBannersFormRegionSelector) { jBannersFormRegionSelector.onSelect(id, title, ex); } }',
'placeholder' => Geo::coveringType(Geo::COVERING_COUNTRIES) ? _t('@', 'Country / Region / City') : _t('@', 'Region')
]); ?>
'__id__', 'title' => '__title__')) use ($name) { tpl::start(); ?>
= $r['title'] ?>
= _t('@', 'In All Regions'); ?>
$v['region_id'], 'title' => $showCountry && isset($countries[ $v['geo_region1'] ]) ? $countries[ $v['geo_region1'] ]['title'].' / '.$v['region']['title'] : $v['region']['title']));
}
} ?>
end()
->rule(TYPE_ARRAY_UINT)
->after('pages')
;}
$form
->custom('category_id', _t('@banners', 'Category'))->getCustom()
->onView(function($view, $field) use ($form) {
/** @var bff\tpl\admin\form\Custom $field */
$data = $form->_data();
$name = $field->name();
$raw = [];
if (isset($data[$name])) {
$raw = $data[$name];
$raw = ( ! empty($raw) ? explode(',', $raw) : []);
}
$categories = function($module) use (& $raw, $name) {
$data = Banners::getCategories($module, [], 'array');
tpl::start(); ?>
= $categories('listings') ?>
= bff::businessEnabled() ? $categories('business') : '' ?>
end()
->onValidate(function($param) use ($form){
$result = & $param['value'];
foreach ($result as $k => $v) {
if (empty($v)) {
unset($result[$k]);
}
}
if (empty($result)) {
$result = [Banners::CATEGORY_ALL];
}
$result = join(',', $result);
return true;
})
->after('pages')
;