silverstripe-userforms/code/model/formfields/EditableCountryDropdownField.php

39 lines
807 B
PHP
Raw Normal View History

<?php
/**
* A dropdown field which allows the user to select a country
*
* @package userforms
*/
class EditableCountryDropdownField extends EditableFormField {
2013-06-02 14:05:16 +12:00
private static $singular_name = 'Country Dropdown';
2013-06-02 14:05:16 +12:00
private static $plural_name = 'Country Dropdowns';
2015-07-24 14:37:48 +12:00
/**
* @return FieldList
*/
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeByName('Default');
return $fields;
}
public function getFormField() {
2015-07-24 14:37:48 +12:00
return CountryDropdownField::create($this->Name, $this->Title);
}
public function getValueFromData($data) {
if(isset($data[$this->Name])) {
$source = $this->getFormField()->getSource();
return $source[$data[$this->Name]];
}
}
public function getIcon() {
return USERFORMS_DIR . '/images/editabledropdown.png';
}
}