Components
Call Form.api.bindevent($('form[role=form]')) so widgets bind.
Upload
Input + .plupload (+ optional .fachoose / preview). Key attrs: data-input-id, data-mimetype, data-multiple, data-preview-id. Cloud storage via storage driver addons.
SelectPage
<input class="form-control selectpage" data-source="category/selectpage" data-field="name">
Editor
Use class="editor" only. Drivers register the implementation — do not hardcode a vendor editor in business code.
Validation
Nice-validator via data-rule. Add novalidate on the form to disable.
Tree select options (Pid / parent)
Use tree_select_options() (in app/common.php) whenever a form needs a hierarchical parent/category dropdown. Same look as system Category / Auth Rule trees.
$rows = Db::name('my_category')->order('weigh desc,id asc')->select()->toArray();
// optional: localize $rows[*]['name'] first
$parentList = tree_select_options($rows, 'name', 'pid', lang('None'), $excludeIds);
$this->view->assign('parentList', $parentList);
<select class="form-control selectpicker" name="row[pid]" data-live-search="true">
{foreach name="parentList" item="vo"}
<option value="{$key}">{$vo|raw}</option>
{/foreach}
</select>
- Labels include Tree spacers (
/ ├ / └) — always output with|raw. - Pass
$excludeIdson edit (self + descendants) so a node cannot nest under itself. - Reference: store Category admin, core
CategoryPid select.
Módulos AMD del admin (diálogos add / edit)
Add/Edit abre un iframe Layer separado. Si el define('backend/…') solo está en index.html, RequireJS intenta cargar un JS inexistente y fallan upload/choose.
- Incluir el mismo AMD en
index/add/edit(p. ej.script.html). - No crear JS por página en
public/assets/js/backend/**. - Tras filas dinámicas:
Form.events.faupload+Form.events.faselect.
build_upload_field()
Usar build_upload_field() para campos de imagen/archivo en admin (.faupload + .fachoose). Modos: image/images/file/files/media/medias.