/**
  * Jedem Language-Element in den Unterformularen wird ein Validator hinzugefügt. Formulare ohne Language-Element
  * werden ignoriert.
  */
 public function testPrepareValidation()
 {
     $form = new Zend_Form();
     $titleCount = 3;
     for ($index = 0; $index < $titleCount; $index++) {
         $subform = new Zend_Form_SubForm();
         $subform->addElement(new Application_Form_Element_Language('Language'));
         $form->addSubForm($subform, 'Title' . $index);
     }
     $subform = new Zend_Form_Subform();
     $subform->addElement('submit', 'Add');
     $form->addSubForm($subform, 'Actions');
     $instance = new Application_Form_Validate_MultiSubForm_RepeatedLanguages();
     $post = array('Title0' => array('Id' => '1', 'Language' => 'deu', 'Value' => 'Titel 1'), 'Title1' => array('Id' => '2', 'Language' => 'fra', 'Value' => 'Titel 2'), 'Title2' => array('Id' => '3', 'Language' => 'rus', 'Value' => 'Titel 3'), 'Actions' => array('Add' => 'Add'));
     $instance->prepareValidation($form, $post);
     for ($index = 0; $index < $titleCount; $index++) {
         $subform = $form->getSubForm('Title' . $index);
         $validator = $subform->getElement('Language')->getValidator('Application_Form_Validate_LanguageUsedOnceOnly');
         $this->assertNotNull($validator);
         $this->assertEquals($index, $validator->getPosition());
         $this->assertEquals(array('deu', 'fra', 'rus'), $validator->getLanguages());
     }
 }
Example #2
0
 /**
  * Create a module selection form for system installation
  *
  * @param array|Zend_Config $options
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('modules');
     $this->setLegend('Modules');
     $mod_dir = ZfApplication::$_base_path . "/app";
     $iterator = new DirectoryIterator($mod_dir);
     foreach ($iterator as $file) {
         if ($file->isDir() && $file->getFilename() != "." && $file->getFilename() != ".." && substr($file->getFilename(), 0, 1) != ".") {
             $module = new Zend_Form_Element_Checkbox($file->getFilename(), array('value' => 1));
             $module->setAttrib('id', 'modules_' . $file->getFilename())->setLabel($file->getFilename());
             $this->addElement($module);
         }
     }
 }
Example #3
0
 /**
  * Create system settings configuration form
  *
  * @param array|Zend_Config $options
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('settings');
     $this->setLegend('Settings');
     $theme = new Zend_Form_Element_Select('theme', array('label' => "Default theme"));
     $mod_dir = ZfApplication::$_doc_root . "/themes";
     $iterator = new DirectoryIterator($mod_dir);
     foreach ($iterator as $file) {
         if ($file->isDir() && $file->getFilename() != "." && $file->getFilename() != ".." && substr($file->getFilename(), 0, 1) != ".") {
             $options[$file->getFilename()] = $file->getFilename();
         }
     }
     $theme->addMultiOptions($options);
     $sitename = new Zend_Form_Element_Text('sitename', array('label' => "Site name"));
     $sitename->addValidator('stringLength', false, array(6, 20));
     $sitename->setRequired();
     $this->addElement($sitename);
     $this->addElement($theme, 'theme');
 }