Ejemplo n.º 1
0
    /**
     * Shows the control.
     * 
     * @since 1.0.0
     * @return void
     */
    public function render()
    {
        $this->addCssClass('factory-from-control-' . $this->type);
        $isActive = $this->provider->getValue($this->getOption('name') . '_is_active', $this->getOption('isActive', 1));
        // if the control is off, then ignore it
        $off = $this->getOption('off', false);
        if ($off) {
            return;
        }
        ?>
        <input type="hidden" class="factory-control-is-active" name="<?php 
        echo $this->getOption('name');
        ?>
_is_active" value="<?php 
        echo $isActive;
        ?>
" />
        <?php 
        $this->beforeHtml();
        $this->html();
        $this->afterHtml();
    }
Ejemplo n.º 2
0
 /**
  * Saves form data by using a specified value provider.
  * 
  * @since 1.0.0
  * @return void
  */
 public function save()
 {
     if (!$this->provider) {
         return;
     }
     $controls = $this->getControls();
     foreach ($controls as $control) {
         $values = $control->getValuesToSave();
         foreach ($values as $keyToSave => $valueToSave) {
             $this->provider->setValue($keyToSave, $valueToSave);
         }
         $nameOption = $control->getOption('name') . '_is_active';
         $isActive = isset($_POST[$nameOption]) && intval($_POST[$nameOption]) == 0 ? 0 : 1;
         $this->provider->setValue($nameOption, $isActive);
     }
     return $this->provider->saveChanges();
 }