InvoicerPickerRefreshTrait
Shared hidden `*Refresh` submit buttons of the seller/customer/delivery address pickers for both big forms (`Invoice` and `InvoiceTemplate`).
After a pick picker.js clicks the button (naja); the server fills the snapshot from the picked
entity and redraws the invoiceForm snippet (both edit.latte use the same snippet name).
Depends on methods of SellerPickerTrait
and CustomerPickerTrait (loadSeller,
loadCustomer, sellerPrefillData, customerPrefillData, customerFieldMap,
customerDeliveryFieldMap); the host presenter must have them.
Table of Contents
Methods
- addPickerRefreshButtons() : void
- Hidden `*Refresh` submit buttons: after a pick, `picker.js` clicks them (naja), the server fills the seller/customer snapshot from the picked entity (nested contacts/accounts too) and redraws the block snippet.
- fillMappedFields() : void
- Force-sets form fields from prefill data through a fieldMap (data key to field name; an empty map means the key is the field name, as for the seller). Only existing fields; a checkbox becomes bool.
- pickedId() : int
- Reads the picked id safely from the hidden picker field (after submit).
- pickerRefreshButton() : void
Methods
addPickerRefreshButtons()
Hidden `*Refresh` submit buttons: after a pick, `picker.js` clicks them (naja), the server fills the seller/customer snapshot from the picked entity (nested contacts/accounts too) and redraws the block snippet.
private
addPickerRefreshButtons(Form $form) : void
validationScope([]) skips validation (a required line does not block it); the createForm
gate lets only update/save save, so this does not save. useVat is handled by the client
(fieldMap + change, invoice-calc recalculates VAT at once); the server fills only the text
fields of the block.
Parameters
- $form : Form
fillMappedFields()
Force-sets form fields from prefill data through a fieldMap (data key to field name; an empty map means the key is the field name, as for the seller). Only existing fields; a checkbox becomes bool.
private
fillMappedFields(Form $form, array<string, string> $data, array<string, string> $fieldMap) : void
Parameters
- $form : Form
- $data : array<string, string>
- $fieldMap : array<string, string>
pickedId()
Reads the picked id safely from the hidden picker field (after submit).
private
pickedId(Form $form, string $field) : int
Parameters
- $form : Form
- $field : string
Return values
intpickerRefreshButton()
private
pickerRefreshButton(Form $form, string $name, callable $apply) : void
Parameters
- $form : Form
- $name : string
- $apply : callable