2013-04-24 18:57:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A dropdown field which allows the user to select a country
|
|
|
|
*
|
|
|
|
* @package userforms
|
|
|
|
*/
|
|
|
|
class EditableCountryDropdownField extends EditableFormField {
|
|
|
|
|
2013-06-02 04:05:16 +02:00
|
|
|
private static $singular_name = 'Country Dropdown';
|
2013-04-24 18:57:33 +02:00
|
|
|
|
2013-06-02 04:05:16 +02:00
|
|
|
private static $plural_name = 'Country Dropdowns';
|
2015-07-24 04:37:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return FieldList
|
|
|
|
*/
|
|
|
|
public function getCMSFields() {
|
|
|
|
$fields = parent::getCMSFields();
|
|
|
|
|
|
|
|
$fields->removeByName('Default');
|
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
2013-04-24 18:57:33 +02:00
|
|
|
|
|
|
|
public function getFormField() {
|
2015-08-10 07:03:36 +02:00
|
|
|
$field = CountryDropdownField::create($this->Name, $this->EscapedTitle);
|
|
|
|
$this->doUpdateFormField($field);
|
|
|
|
return $field;
|
2013-04-24 18:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getValueFromData($data) {
|
|
|
|
if(isset($data[$this->Name])) {
|
2013-08-29 04:03:09 +02:00
|
|
|
$source = $this->getFormField()->getSource();
|
|
|
|
return $source[$data[$this->Name]];
|
2013-04-24 18:57:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
2014-04-16 01:48:10 +02:00
|
|
|
return USERFORMS_DIR . '/images/editabledropdown.png';
|
2013-04-24 18:57:33 +02:00
|
|
|
}
|
2015-08-13 01:31:37 +02:00
|
|
|
|
|
|
|
public function getSelectorField(EditableCustomRule $rule, $forOnLoad = false) {
|
|
|
|
return "$(\"select[name='{$this->Name}']\")";
|
|
|
|
}
|
2013-04-24 18:57:33 +02:00
|
|
|
}
|