Exemplo n.º 1
0
 /**
  * Create singleton version of particular type of form field.
  *
  * @overwritten
  * @access   public
  * @param    string $sType
  * @return   Form\Field
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function cloneToOtherType($sType)
 {
     $oField = parent::cloneToOtherType($sType);
     /* @var $oField Select */
     $aOptions = [];
     switch ($sType) {
         case 'select':
             foreach ($this->getOptions() as $aOption) {
                 $aOptions[$aOption['value']] = $aOption['label'];
             }
             $oField->setOptions($aOptions);
             break;
     }
     return $oField;
 }
Exemplo n.º 2
0
 /**
  * Get field value.
  *
  * @access   public
  * @param    string  $lang
  * @param    integer $valueNumber
  * @return   mixed
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function getValue($lang = NULL, $valueNumber = NULL)
 {
     return parent::getValue($lang, $valueNumber);
     // TODO: Change the autogenerated stub
 }
Exemplo n.º 3
0
 /**
  * Constructor.
  *
  * @access   public
  * @param    string $name
  * @param    Form   $form
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function __construct($name, Form &$form)
 {
     parent::__construct($name, $form);
     $this->getAttributes()->addToAttribute('class', 'form-control');
 }
Exemplo n.º 4
0
 /**
  * Add field form of particular name.
  *
  * @access     public
  * @param      Form\Field $oField
  * @return     MConfig
  * @since      1.0.0-alpha
  * @version    1.0.0-alpha
  */
 public function addField(Form\Field $oField)
 {
     $this->aFields[$oField->getName()] = $oField;
     return $this;
 }
Exemplo n.º 5
0
 /**
  * @access   public
  * @param    string $name
  * @param    Form   $form
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function __construct($name, Form &$form)
 {
     parent::__construct($name, $form);
     $this->getAttributes()->setAttribute('type', 'text');
     $this->getAttributes()->addToAttribute('class', 'form-control input-sm');
 }
Exemplo n.º 6
0
 /**
  * Make data transfer (set values) from Form to Model.
  *
  * @access   protected
  * @param    string     $sName
  * @param    array      $aValue
  * @param    Form\Field $oFormField
  * @return   boolean
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 protected function makeDataTransfer($sName, $aValue, Form\Field &$oFormField)
 {
     $aCheckedLanguages = $oFormField->getFormObject()->getCheckedLanguages();
     if ($oFormField->isMultilanguage()) {
         foreach (Core::getLanguages() as $sLang) {
             if (!isset($aValue[$sLang]) && in_array($sLang, $aCheckedLanguages)) {
                 $aValue[$sLang] = NULL;
             }
         }
     }
     foreach ($aValue as $sLang => $aAllValues) {
         if (!in_array($sLang, $aCheckedLanguages)) {
             continue;
         }
         if (!empty($aAllValues)) {
             $mValue = $oFormField->getQuantity() === 1 ? array_shift($aAllValues) : array_values($aAllValues);
         } else {
             $mValue = NULL;
         }
         if ($sLang === 'und') {
             if (is_array($mValue)) {
                 $mValue = array_values($mValue);
             }
             $this->getModel()->{$sName} = $mValue;
         } else {
             $this->getModel()->getLocales($sLang)->{$sName} = $mValue;
         }
     }
     return TRUE;
 }
Exemplo n.º 7
0
 /**
  * Add singleton field to this form.
  *
  * @access   public
  * @param    Form\Field $oField
  * @return   Form
  * @throws   Exception
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function addSingleton(Field $oField)
 {
     if ($oField->getFormObject()->getName() !== 'singletons') {
         throw new Exception('This field is not a singleton.');
     }
     $oField->setFormIfSingleton($this);
     $this->fields[$oField->getName()] = $oField;
     return $this;
 }
Exemplo n.º 8
0
 /**
  * Constructor
  *
  * @access   public
  * @param    string $name
  * @param    Form   $form
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function __construct($name, Form &$form)
 {
     parent::__construct($name, $form);
     $mValue = $this->getValue();
     if (empty($mValue)) {
         $this->setValue(['day' => '', 'month' => '', 'year' => '']);
     }
 }
Exemplo n.º 9
0
 /**
  * Render field and return its rendered value.
  *
  * @access   public
  * @return   string
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function render()
 {
     return Config::get('recaptcha.active') === FALSE ? '' : parent::render();
 }