/** * 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; }
/** * Fields config for backend. * * @access public * @return ModelCore\MConfig * @since 1.0.0-alpha * @version 1.0.0-alpha */ protected static function generateConfig() { $oConfig = parent::generateConfig(); $currentRouteName = Router::getCurrentRouteName(); $currentRouteParams = Router::getParams(); $oConfig->addField(Form\Field\Hidden::singleton('id')->setLabel(__('ID'))->setDisabled()); // BACKEND if ($currentRouteName === 'backend' && in_array($currentRouteParams['action'], ['edit', 'list'])) { $oConfig->addField(Form\Field\Text::singleton('name')->setLabel(__('File name'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('ext')->setLabel(__('File extension'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('file_path')->setLabel(__('File path'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('mime')->setLabel(__('File MIME type'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('size')->setLabel(__('File size'))->setTip(__('File size in KB.'))->setDisabled()); $oConfig->addField(Form\Field\Select::singleton('status')->setOptions([0 => __('Temporary'), 1 => __('Permanent')])->setLabel(__('Status'))->setDisabled()); } return $oConfig; }
/** * Fields config for backend. * * @access public * @return ModelCore\MConfig * @since 1.0.0 * @version 1.0.3-dev, 2015-04-29 */ protected static function generateConfig() { # create config $config = parent::generateConfig(); # create fields $config->addField(Form\Field\Hidden::singleton('id')->setLabel('ID')->setDisabled()); $config->addField(Form\Field\Select::singleton('published')->setOptions(['Nie', 'Tak'])->setLabel(__('Published'))->setRequired()->addRulesSet(Validator\RulesSetBuilder::factory()->addRule(['in_array', [':value', [1, 0]]]))); $config->addField(Form\Field\Text::singleton('title')->setLabel(__('Title'))->setRequired()); $config->addField(Form\Field\Text::singleton('rewrite')->setRequired()->setLabel(__('URL alias'))); $config->addField(Form\Field\Text::singleton('keywords')->setLabel(__('Keywords'))); $config->addField(Form\Field\ImageModel::singleton('image')->setBrokerModel('\\Model\\Page\\Image')->setUploadPath('uploads/page')->setRequired()->setLabel(__('Image'))->addRulesSet(Validator\RulesSetBuilder\ImageModel::factory()->allowedExt(':value', ['jpg', 'gif', 'png', 'jpeg']))); $config->addField(Form\Field\FileModel::singleton('files')->setBrokerModel('\\Model\\Page\\File')->setUploadPath('uploads/page_files')->setQuantity(0)->setLabel(__('Attachments'))->addRulesSet(Validator\RulesSetBuilder\ImageModel::factory()->allowedExt(':value', ['txt', 'pdf', 'docx', 'doc', 'rtf', 'zip']))); $config->addField(Form\Field\Textarea::singleton('description')->setLabel(__('Description'))); $config->addField(Form\Field\Tinymce::singleton('content')->setRequired()->setLabel(__('Content'))); # return config return $config; }