/**
  * Initiate the standard Metadata catalogue search form. The 
  * additional parameter $defaults defines the default values for the form.
  * 
  * @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
  * @param String $name The method on the controller that will return this form object.
  * @param FieldSet $fields All of the fields in the form - a {@link FieldSet} of {@link FormField} objects.
  * @param FieldSet $actions All of the action buttons in the form - a {@link FieldSet} of {@link FormAction} objects
  * @param Validator $validator Override the default validator instance (Default: {@link RequiredFields})
  * @param Array $defaults Override the default values of the form.		 
  */
 function __construct($controller, $name, FieldSet $fields = null, FieldSet $actions = null, $validator = null, $defaults = null)
 {
     $format = $defaults['format'];
     $searchTerm = $defaults['searchTerm'];
     $bboxUpper = $bboxLower = null;
     if (isset($defaults['bboxUpper']) && isset($defaults['bboxLower'])) {
         $bboxUpper = $defaults['bboxUpper'];
         $bboxLower = $defaults['bboxLower'];
     }
     $values = CataloguePage_Controller::get_standard_names();
     $upperField = new HiddenField('bboxUpper', _t('SearchForm.SEARCH', 'bboxUpper'), $bboxUpper);
     $upperField->addExtraClass('upper');
     $lowerField = new HiddenField('bboxLower', _t('SearchForm.SEARCH', 'bboxLower'), $bboxLower);
     $lowerField->addExtraClass('lower');
     if (!$fields) {
         $fields = new FieldSet(new TextField('searchTerm', _t('SearchForm.SEARCH', 'Search'), $searchTerm), $upperField, $lowerField, new OptionsetField('format', _t('SearchForm.MetadataStandard', 'Metadata Standard'), $values, $format));
     }
     if (singleton('SiteTree')->hasExtension('Translatable')) {
         $fields->push(new HiddenField('locale', 'locale', Translatable::get_current_locale()));
     }
     if (!$actions) {
         $actions = new FieldSet(new FormAction("submit", _t('SearchForm.Search', 'Search')));
     }
     parent::__construct($controller, $name, $fields, $actions);
     $this->setFormMethod('get');
 }
 public function GameSignupFields($reg)
 {
     $fields = new FieldList();
     $currentID = $this->getCurrentEvent()->ID;
     $event = Event::get()->byID($currentID);
     $prefNum = $event->PreferencesPerSession;
     $reg = $this->getCurrentRegistration();
     $fields->push(new HiddenField('RegistrationID', 'Reg', $reg->ID));
     $fields->push($fav = new HiddenField('FavouriteID', 'Favourite'));
     $fav->addExtraClass('favourite-id');
     $fields->push(new LiteralField('no-js', '<p class="js-hide">This page works better with javascript. If you can\'t use javascript, rank the items below in your order of preference. 1 for your first choice, 2 for your second. Note, only the top ' . $prefNum . ' will be recorded</p>'));
     for ($session = 1; $session <= $event->NumberOfSessions; $session++) {
         $evenOdd = $session % 2 == 0 ? 'even' : 'odd';
         $fieldset = '<fieldset id="round' . $session . '" class="preference-group preference-' . $prefNum . ' data-preference-select="preference-select-group">';
         $fields->push(new LiteralField('Heading_' . $session, '<h5>Round ' . $session . ' preferences</h5>' . $fieldset));
         $games = Game::get()->filter(array('Session' => $session, 'ParentID' => $currentID, 'Status' => true))->sort('RAND()');
         $i = 1;
         foreach ($games as $game) {
             $gameOptions = new NumericField("GameID_" . $game->ID, '');
             $gameOptions->setValue($i)->setRightTitle($game->Title)->setAttribute('type', 'number')->setAttribute('data-id', $game->ID)->addExtraClass('small-input js-hide-input');
             $fields->push($gameOptions);
             $i++;
         }
         // Add not playing option
         $gameOptions = new NumericField("NotPlaying_" . $session, '');
         $gameOptions->setValue($i)->setRightTitle("No game (or Facilitating)")->setAttribute('type', 'number')->addExtraClass('small-input js-hide-input not-playing');
         $fields->push($gameOptions);
         $fields->push(new LiteralField('fieldset', '</fieldset>'));
     }
     return $fields;
 }
 public function getColumnContent($grid, $record, $col)
 {
     // In case you are using GridFieldEditableColumns, this ensures that
     // the correct sort order is saved. If you are not using that component,
     // this will be ignored by other components, but will still work for this.
     $sortFieldName = sprintf('%s[GridFieldEditableColumns][%s][%s]', $grid->getName(), $record->ID, $this->getSortField());
     $sortField = new HiddenField($sortFieldName, false, $record->getField($this->getSortField()));
     $sortField->addExtraClass('ss-orderable-hidden-sort');
     $sortField->setForm($grid->getForm());
     return ViewableData::create()->customise(array('SortField' => $sortField))->renderWith('GridFieldOrderableRowsDragHandle');
 }
 /**
  * put together a dropdown for the country field
  *
  * @param String $name - name of the field
  * @return DropdownField
  **/
 protected function getCountryField($name)
 {
     $countriesForDropdown = EcommerceCountry::list_of_allowed_entries_for_dropdown();
     $title = _t("OrderAddress." . strtoupper($name), "Country");
     $countryField = new DropdownField($name, $title, $countriesForDropdown, EcommerceCountry::get_country());
     $countryField->setRightTitle(_t("OrderAddress." . strtoupper($name) . "_RIGHT", ""));
     if (count($countriesForDropdown) < 2) {
         $countryField = $countryField->performReadonlyTransformation();
         if (count($countriesForDropdown) < 1) {
             $countryField = new HiddenField($name, '', "not available");
         }
     }
     $prefix = EcommerceConfig::get("OrderAddress", "field_class_and_id_prefix");
     $countryField->addExtraClass($prefix . 'ajaxCountryField');
     //important, otherwise loadData will override the default value....
     $this->{$name} = EcommerceCountry::get_country();
     return $countryField;
 }
 /**
  * put together a dropdown for the country field
  * @param String $name - name of the field
  * @return DropdownField
  **/
 protected function getCountryField($name)
 {
     $countriesForDropdown = EcommerceCountry::list_of_allowed_entries_for_dropdown();
     $countryField = new DropdownField($name, EcommerceCountry::i18n_singular_name(), $countriesForDropdown, EcommerceCountry::get_country());
     if (count($countriesForDropdown) < 2) {
         $countryField = $countryField->performReadonlyTransformation();
         if (count($countriesForDropdown) < 1) {
             $countryField = new HiddenField($name, '', "not available");
         }
     }
     $prefix = EcommerceConfig::get("OrderAddress", "field_class_and_id_prefix");
     $countryField->addExtraClass($prefix . 'ajaxCountryField');
     return $countryField;
 }