public function updateLinkForm($form)
 {
     Requirements::javascript("linkableobjects/javascript/CustomHtmlEditorField.js");
     $count = 0;
     foreach ($form->Fields() as $field) {
         $count++;
         if ($count == 2) {
             $linkType = $field->fieldByName('LinkType');
             $types = $linkType->getSource();
             $link = new HtmlEditorField_LinkObjects();
             $linkableObjects = $link->getLinkableObjects();
             foreach ($linkableObjects as $object => $title) {
                 $types[$object] = $title;
                 $picker = new DataObjectPicker($object . 'LinkID', $title);
                 $picker->setConfig('limit', 5);
                 $picker->setConfig('classToPick', $object);
                 $picker->setForm($form);
                 $field->insertBefore($picker, 'Description');
             }
             $linkMap = new HiddenField('LinkableObjects');
             $linkMap->setAttribute('data-map', json_encode($linkableObjects));
             $field->push($linkMap);
             $linkType->setSource($types);
         }
     }
 }
 /**
  * The construct function can optionally take an array of objects to add to $linkable_objects
  * and a boolean variable which decides whether to overwrite the $linkable_objects field
  * or simply add the array values to it.
  */
 public function __construct($objects = null, $overwrite = false)
 {
     // Check if $objects is an array first
     if (is_array($objects)) {
         // If the overwrite variable is set
         if ($overwrite) {
             // Replace $linkable_objects with the passed array
             self::$linkable_objects = $objects;
         } else {
             // Otherwise, merge the arrays together
             self::$linkable_objects = array_merge(self::$linkable_objects, $objects);
         }
     }
 }