Example #1
0
 /**
  * Load the form
  */
 protected function loadForm()
 {
     $addressCheckboxes = array();
     // create form
     $this->frm = new BackendForm('edit');
     $this->frm->addText('title', $this->record['title']);
     $this->frm->addHidden("id", $this->id);
     $groups = BackendAddressesModel::getAllGroupsForDropdown(false);
     array_unshift($groups, "");
     $this->frm->addDropdown('group', $groups, $this->record['parent_id']);
     //--Get all the users
     $addresses = BackendAddressesModel::getAllAddresses($this->id);
     if (!empty($addresses)) {
         //--Loop all the users
         foreach ($addresses as &$address) {
             $strAddress = $address["name"] != "" ? " (" . $address["name"] . " " . $address["firstname"] . ")" : "";
             $addressCheckboxes[] = array("label" => $address["company"] . $strAddress, "value" => $address["id"]);
         }
         //--Get the users from the group
         $addressesGroup = BackendAddressesModel::getAddressesForGroup($this->id);
         //--Create a selected-array
         $addressesCheckboxesSelected = count($addressesGroup) > 0 ? array_keys($addressesGroup) : null;
         //--Add multicheckboxes to form
         $this->frm->addMultiCheckbox("addresses", $addressCheckboxes, $addressesCheckboxesSelected);
     }
     // meta
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true);
     $this->meta->setUrlCallback('Backend\\Modules\\Addresses\\Engine\\Model', 'getUrlForGroup', array($this->record['id']));
 }