/** * Generate Config. * * @static * @access public * @return ModelCore\MConfig * @since 1.0.0-alpha * @version 1.0.0-alpha */ public static function generateConfig() { // get Config from parent $config = parent::generateConfig(); // BACKEND $config->addField(Form\Field\Hidden::singleton('id')->setLabel(__('ID'))->setDisabled()); $config->addField(Form\Field\Text::singleton('title')->setLabel(__('Title'))); $config->addField(Form\Field\Textarea::singleton('description')->setLabel(__('Description'))); // return Config return $config; }
/** * Fields config for backend. * * @access public * @return MConfig * @since 1.0.0 * @version 2.1.0-dev */ protected static function generateConfig() { # get all permissions list $aRoles = []; $aResult = DB::queryList('\\Model\\User\\Role')->execute(); foreach ($aResult as $oRole) { /* @var $oRole User\Role */ $aRoles[] = ['value' => $oRole->getId(), 'label' => $oRole->getName()]; } # get config from parent $config = parent::generateConfig(); # create fields $config->addField(FormField\Hidden::singleton('id')->setLabel(__('ID'))->setDisabled()); $config->addField(FormFieldPassword::singleton('password')->setLabel(__('Password'))->addRulesSet(RulesSetBuilder\String::factory()->containNumbers(':value')->containText(':value')->containUppercase(':value')->containCustomCharacters(':value'))); $config->addField(FormField\Text::singleton('login')->setLabel('Login')->addTipParagraph(__('This value can contain only letters, numbers and "-" or "_" characters.'))->setDisabled()->addRulesSet(RulesSetBuilder\String::factory()->onlyLettersNumsAndChars(':value', '\\-_', __('This value can contain only letters, numbers and "-" or "_" characters.')))->addRulesSet(RulesSetBuilder\Database::factory()->unique(':value', ':valuefrom:id', '\\Model\\User', 'login'))); $config->addField(FormField\Text::singleton('email')->setLabel('E-mail')->setDisabled()->addRulesSet(RulesSetBuilder\String::factory()->email(':value'))->addRulesSet(RulesSetBuilder\Database::factory()->unique(':value', ':valuefrom:id', '\\Model\\User', 'email'))); $config->addField(FormField\Text::singleton('firstname')->setLabel(__('Firstname'))->addRulesSet(RulesSetBuilder\String::factory()->onlyLetters(':value'))); $config->addField(FormField\Text::singleton('lastname')->setLabel(__('Lastname'))->addRulesSet(RulesSetBuilder\String::factory()->onlyLetters(':value'))); $config->addField(FormField\Text::singleton('nickname')->setLabel(__('Nickname'))); $config->addField(FormField\ImageModel::singleton('image')->setBrokerModel('\\Model\\User\\Image')->setUploadPath('uploads/users/image')->setLabel(__('Image'))->addRulesSet(RulesSetBuilder\FileModel::factory()->allowedExt(':value', ['jpg', 'png', 'gif'])->maxSize(':value', 1024))); $config->addField(FormField\Text::singleton('city')->setLabel(__('City'))->addRulesSet(RulesSetBuilder\String::factory()->onlyLetters(':value'))); $config->addField(FormField\Textarea::singleton('description')->setLabel(__('Description'))); if (\UserPermissions::hasPerm('users_edit')) { $config->addField(CheckboxRelationFormField::singleton('roles')->setRelatedModelName('\\Model\\User\\Role')->setOptions($aRoles)->setLabel(__('Roles'))); } $config->addFieldFormatter('registration_date', FieldFormatterDate::factory()); $config->addFieldFormatter('login_date', FieldFormatterDate::factory()); # return config return $config; }
/** * Generate config object of particular Model. * * @static * @author Krzysztof Trzos * @access protected * @return ModelCore\MConfig * @since 1.1.0, 2015-01-10 * @version 1.1.0, 2015-01-10 */ public static function generateConfig() { $oConfig = parent::generateConfig(); $oConfig->addField(Form\Field\Textarea::singleton('description')->setLabel('Opis')); return $oConfig; }
/** * Constructor * * @access public * @param string $name field name * @param Form $form form * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function __construct($name, Form &$form) { parent::__construct($name, $form); $attributes = $this->getAttributes(); $attributes->addToAttribute('class', 'tinymce_editor'); }
/** * 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; }