public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Capacity');
     $fields->removeByName('Registrations');
     $fields->removeByName('Tickets');
     $fields->removeByName('EmailReminder');
     $fields->removeByName('RemindDays');
     $fields->removeByName('PaymentID');
     $fields->removeByName('ReminderJobID');
     if (!$this->isInDB()) {
         $fields->push(new LiteralField('RegistrationNote', '<p>You can configure registration once ' . 'you save for the first time.</p>'));
         return $fields;
     }
     $fields->push(new GridField('Tickets', _t('EventManagement.AVAILABLE_TICKETS', 'Available Tickets'), $this->Tickets(), GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent($add = new GridFieldAddExistingSearchButton())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldOrderableRows('Sort'))->addComponent($editable = new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction(true))));
     $fields->push($capacity = new NumericField('Capacity', _t('EventManagement.CAPACITY', 'Capacity')));
     $editable->setDisplayFields(array('Title' => array('title' => 'Title', 'field' => 'ReadonlyField'), 'StartSummary' => 'Sales Start', 'PriceSummary' => 'Price', 'Available' => array('field' => 'NumericField')));
     $add->setTitle(_t('EventManagement.ADD_TICKET_TYPE', 'Add Ticket Type'));
     $capacity->setDescription('Set to 0 for unlimited capacity.');
     if (class_exists('AbstractQueuedJob')) {
         if ($this->ReminderJobID && $this->ReminderJob()->StepsProcessed) {
             $fields->push(new LiteralField('RemindersAlreadySent', '<p>Reminder emails have already been sent out.</p>'));
         } else {
             $fields->push(new CheckboxField('EmailReminder', _t('EventManagement.SEND_REMINDER_EMAIL', 'Send the registered attendees a reminder email?')));
             $fields->push($remindDays = new NumericField('RemindDays', _t('EventManagement.SEND_REMINDER', 'Send reminder')));
             $remindDays->setDescription(_t('EventManagement.DAYS_BEFORE_EVENT', 'Days before the event starts.'));
         }
     }
     return $fields;
 }
 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     $classes = $this->blockManager->getBlockClasses();
     $this->addComponent($add = new GridFieldAddExistingSearchButton());
     $add->setSearchList(Block::get()->filter(array('ClassName' => array_keys($classes))));
     return $this;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('LinkedFromCities');
     $grid = new GridField('LinkedToCities', $this->fieldLabel('LinkedToCities'), $this->LinkedToCities(), GridFieldConfig::create()->addComponent(new GridFieldDetailForm())->addComponent(new GridFieldButtonRow())->addComponent($GridFieldAddExistingSearchButton = new GridFieldAddExistingSearchButton('buttons-before-right'))->addComponent($GridFieldAddExistingAutocompleter = new GridFieldAddExistingAutocompleter('buttons-before-right'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent($comp = new GridFieldEditableColumns())->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction('unlinkrelation'))->addComponent(new GridFieldDeleteAction())->addComponent($GridFieldAddNewInlineButton = new GridFieldAddNewInlineButton()));
     $GridFieldAddNewInlineButton->setTitle(_t(__CLASS__ . '.AddNewCity', 'Add new city'));
     $GridFieldAddExistingSearchButton->setTitle(_t(__CLASS__ . '.SearchAndAddExistingCity', 'Search and add existing city'));
     $LinkTargetField = MapaelCountryPageExtension::getTargetField($this, 'LinkTarget');
     $LinkTargetField->setTitle(_t(__CLASS__ . '.LinkTarget', 'Link target'));
     $field_names = array_keys(array_merge($this->summaryFields(), self::$many_many_extraFields['LinkedToCities']));
     $arr = array();
     foreach ($field_names as $name) {
         preg_match('/(TooltipContent|Href|Target)$/', $name, $matches);
         $title = $this->fieldLabel($name);
         $arr[$name] = $title;
         if ($matches) {
             $arr[$name] = array('title' => $title, 'callback' => function ($record, $column, $grid) {
                 preg_match('/(TooltipContent|Href|Target)$/', $column, $matches);
                 return MapaelCountryPageExtension::getAttrField($record, $matches[1], $column);
             });
         }
     }
     $comp->setDisplayFields($arr);
     $fields->replaceField('LinkedToCities', $grid);
     $fields->replaceField('Target', MapaelCountryPageExtension::getTargetField($this));
     $fields->replaceField('Href', MapaelCountryPageExtension::getHrefField($this));
     $fields->replaceField('TooltipContent', MapaelCountryPageExtension::getTooltipContentField($this));
     return $fields;
 }
 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     $this->addComponent($add = new GridFieldAddExistingSearchButton());
     $add->setSearchList(Block::get());
     return $this;
 }
 /**
  * @return DataList
  */
 protected function getSearchList()
 {
     return $this->button->getSearchList() ?: DataList::create($this->grid->getList()->dataClass());
 }
 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     // EDIT
     //$this->addComponent($add = new GridFieldAddExistingSearchButton());
     $this->addComponent($add = new GridFieldAddExistingSearchButton('buttons-after-right'));
     // /EDIT
     $add->setSearchList(Block::get());
     return $this;
 }