Exemplo n.º 1
0
 /**
  * Adding validation rules set generated by RulesSetBuilder. Additionaly,
  * adds tips related with created rules.
  *
  * @access     public
  * @param      RulesSetBuilder $oBuilder
  * @return     Field
  * @since      1.0.0-alpha
  * @version    1.0.0-alpha
  */
 public function addRulesSet(RulesSetBuilder $oBuilder)
 {
     // rules
     $this->getFormObject()->getValidator()->rules($this->getName(), $oBuilder->getRules());
     // tips
     foreach ($oBuilder->getTips() as $sTip) {
         $this->addTipParagraph($sTip);
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * 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;
 }