Esempio n. 1
0
 /**
  * Fields config for backend.
  *
  * @static
  * @access   protected
  * @return   ModelCore\MConfig
  * @since    1.1.0-dev
  * @version  1.3.0-dev
  */
 protected static function generateConfig()
 {
     // get config from parent
     $config = parent::generateConfig();
     // get list of all routes
     $routesList = array_keys(Router::getRoutes());
     $routesOptions = [];
     foreach ($routesList as $value) {
         $routesOptions[$value] = ['value' => $value, 'label' => $value];
     }
     // BACKEND
     $config->addField(Form\Field\Hidden::singleton('id')->setDisabled());
     $config->addField(Form\Field\Select::singleton('route')->setOptions(array_combine($routesList, $routesList))->setLabel(__('Route'))->setRequired());
     $config->addField(Form\Field\Text::singleton('route_parameters')->setLabel(__('Route parameters'))->setQuantity(0));
     $config->addField(Form\Field\Text::singleton('url')->setLabel('URL'));
     $config->addField(Form\Field\Checkbox::singleton('active_routes')->setColumnsAmount(3)->setOptions($routesOptions)->setLabel(__('Active routes'))->setTip(__('List of routes for which the actual route will be active')));
     $config->addField(Form\Field\Text::singleton('classes')->setLabel(__('HTML classes'))->addRulesSet(Validator\RulesSetBuilder\String::factory()->regex(':value', '[0-9a-z_-]*')));
     // return config
     return $config;
 }
Esempio n. 2
0
 /**
  * Create singleton version of particular type of form field.
  *
  * @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);
     if ($sType === 'select') {
         $oField->getAttributes()->addToAttribute('class', 'form-control input-sm');
     }
     return $oField;
 }