| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace MGModule\DNSManager2\mgLibs\forms;
- use MGModule\DNSManager2 as main;
- /**
- * Select Form Field
- *
- * @author Michal Czech <michael@modulesgarden.com>
- */
- class radioField extends abstractField{
- public $translateOptions = true;
- public $addValueIfNotExits = false;
- public $options;
- public $type = 'radio';
-
- function prepare() {
- if(array_keys($this->options) == range(0, count($this->options) - 1))
- {
- $options = array();
- foreach($this->options as $value)
- {
- $options[$value] = $value;
- }
- $this->options = $options;
- }
- else
- {
- $this->translateOptions = false;
- }
-
- if($this->addValueIfNotExits)
- {
- if($this->value && !isset($this->options[$this->value]))
- {
- $this->options[$this->value] = $this->value;
- }
- }
-
- if($this->translateOptions)
- {
- $options = array();
- foreach($this->options as $value)
- {
- $options[$value] = main\mgLibs\lang::T($this->formName,$this->name,'options',$value);
- }
- $this->options = $options;
- }
-
- if(empty($this->value))
- {
- foreach($this->options as $value => $lbl)break;
- $this->value = $value;
- }
- }
- }
|