Пример #1
0
 public function __construct($forSearch = false)
 {
     parent::__construct();
     if ($forSearch) {
         $radioKind = new Zend_Form_Element_Radio('kind');
         $radioKind->addMultiOptions(array('and' => 'and', 'or' => 'or'));
         $radioKind->setValue('and');
         $radioKind->setLabel('Search field combination:');
         $radioKind->setRequired(true);
         $this->addElement($radioKind);
     }
     $valiAlphaWhiteSpace = new Zend_Validate_Alpha(true);
     $this->addElement('hidden', User::COL_ID, array('required' => true));
     $this->addElement('text', User::COL_USERNAME, array('label' => 'Username = e-mail adress:', 'required' => true, 'validators' => array('EmailAddress', array('StringLength', false, array(6, 40)))));
     $this->addElement('text', User::COL_FIRSTNAME, array('label' => 'First name:', 'required' => true, 'validators' => array($valiAlphaWhiteSpace)));
     $this->addElement('text', User::COL_LASTNAME, array('label' => 'Last name:', 'required' => true, 'validators' => array($valiAlphaWhiteSpace)));
     $this->addElement('password', User::COL_PASSWORD, array('label' => 'Password:'******'required' => true, 'validators' => array(array('StringLength', false, array(6, 20)))));
     $this->addElement('password', self::PASSWORD_CLONE, array('label' => 'Repeat Password:'******'required' => true));
     //due to the rule username=e-mail adress, this field is not viewed
     /*		$this->addElement('text', User::COL_EMAIL, array(	'label'=>'E-mail adress:',
     	     	'required'=>true,
     		 	'validators'=>array('EmailAddress')));*/
     $institutionSelect = new Default_Form_Element_ValuelistSelect(603, User::COL_INSTITUTION);
     $institutionSelect->setRequired(true);
     $institutionSelect->setLabel('Institution:');
     $this->addElement($institutionSelect);
     $this->addElement('text', User::COL_STREET, array('label' => 'Street:', 'validators' => array(new Zend_Validate_Alnum(true))));
     $this->addElement('text', User::COL_CITY, array('label' => 'City:', 'validators' => array($valiAlphaWhiteSpace)));
     $this->addElement('text', User::COL_PHONE, array('label' => 'Phone number:'));
     $this->addElement('text', User::COL_FAX, array('label' => 'Faxsimile number:'));
     $countrySelect = new Default_Form_Element_ValuelistSelect(602, User::COL_COUNTRY);
     $countrySelect->setRequired(true);
     $countrySelect->setLabel('Country:');
     $this->addElement($countrySelect);
     $this->addElement('checkbox', User::COL_ACTIVE, array('label' => 'Active:'));
     $this->addElement('hidden', User::COL_GUID);
     $this->addElement('submit', 'submit', array('label' => 'Submit'));
     $this->addElement('hidden', 'Token');
     $this->setElementFilters(array('StringTrim'));
 }
Пример #2
0
 public function addDynamicElements($attrRowSetArray, $forSearch = false, $forImagesetAttribute = false)
 {
     $this->forSearch = $forSearch;
     //dynamic form elements
     foreach ($attrRowSetArray as $attr) {
         $fromValue = FALSE;
         //column type is nullable
         if (is_null($attr['UNIT'])) {
             $strUnit = '';
         } else {
             $strUnit = '[' . $attr['UNIT'] . ']';
         }
         $attrName = 'ATDE_' . $attr[AttributeDescriptor::COL_ID];
         $attrLabel = $attr[AttributeDescriptor::COL_NAME] . $strUnit . ':';
         if ($attr[AttributeDescriptor::COL_REQUIRED] == 1) {
             $required = TRUE;
         } else {
             $required = FALSE;
         }
         if ($attr[AttributeDescriptor::COL_FORM_TYPE] == 'select') {
             if ($attr[AttributeDescriptor::COL_VALUE_LIST] == 1) {
                 //show select
                 if ($forSearch) {
                     $valiSel = new Default_Form_Element_ValuelistMulticheckbox($attr[AttributeDescriptor::COL_ID], $attrName, array('label' => $attrLabel));
                 } else {
                     $valiSel = new Default_Form_Element_ValuelistSelect($attr[AttributeDescriptor::COL_ID], $attrName, array('label' => $attrLabel, 'required' => $required));
                 }
                 //XXX valids/filters beta state
                 if (isset($attr[AttributeDescriptor::COL_VALIDATORS])) {
                     $valiSel->addValidators($attr[AttributeDescriptor::COL_VALIDATORS]);
                 }
                 if (isset($attr[AttributeDescriptor::COL_FILTERS])) {
                     $valiSel->addFilters($attr[AttributeDescriptor::COL_FILTERS]);
                 }
                 $this->addElement($valiSel);
             }
         } elseif ($attr[AttributeDescriptor::COL_FORM_TYPE] == 'radio') {
             if ($forSearch) {
                 $valiRad = new Default_Form_Element_ValuelistMulticheckbox($attr[AttributeDescriptor::COL_ID], $attrName, array('label' => $attrLabel));
             } else {
                 $valiRad = new Default_Form_Element_ValuelistRadio($attr[AttributeDescriptor::COL_ID], $attrName, array('label' => $attrLabel, 'required' => $required));
             }
             //XXX valids/filters beta state
             if (isset($attr[AttributeDescriptor::COL_VALIDATORS])) {
                 $valiRad->addValidators($attr[AttributeDescriptor::COL_VALIDATORS]);
             }
             if (isset($attr[AttributeDescriptor::COL_FILTERS])) {
                 $valiRad->addFilters($attr[AttributeDescriptor::COL_FILTERS]);
             }
             $this->addElement($valiRad);
         } elseif ($attr[AttributeDescriptor::COL_FORM_TYPE] == 'text') {
             if ($attr[AttributeDescriptor::COL_DATA_TYPE] == 'integer' || $attr[AttributeDescriptor::COL_DATA_TYPE] == 'decimal' || $attr[AttributeDescriptor::COL_DATA_TYPE] == 'date' || $attr[AttributeDescriptor::COL_DATA_TYPE] == 'time' || $attr[AttributeDescriptor::COL_DATA_TYPE] == 'datetime') {
                 if ($forSearch) {
                     //show from/to textfields
                     $sform = new Zend_Form_SubForm(array('elementsBelongto' => $attrName));
                     $sform->addElement('text', 'fromValue', array('label' => $attrLabel . ' FROM'));
                     $sform->addElement('text', 'toValue', array('label' => $attrLabel . ' TO'));
                     $this->addSubForm($sform, $attrName);
                     $fromValue = TRUE;
                 } else {
                     $this->addElement($attr[AttributeDescriptor::COL_FORM_TYPE], $attrName, array('label' => $attrLabel, 'required' => $required));
                 }
             } elseif ($attr[AttributeDescriptor::COL_DATA_TYPE] == 'string') {
                 $this->addElement($attr[AttributeDescriptor::COL_FORM_TYPE], $attrName, array('label' => $attrLabel, 'required' => $required));
             }
         } elseif ($attr[AttributeDescriptor::COL_FORM_TYPE] == 'textarea' && !$forSearch) {
             $this->addElement($attr[AttributeDescriptor::COL_FORM_TYPE], $attrName, array('label' => $attrLabel, 'rows' => '4', 'cols' => '20', 'required' => $required));
         } elseif ($attr[AttributeDescriptor::COL_FORM_TYPE] == 'checkbox') {
             //standard returns 0 for unchecked, 1 for checked, if not set
             $this->addElement($attr[AttributeDescriptor::COL_FORM_TYPE], $attrName, array('label' => $attrLabel, 'required' => $required));
         } elseif ($attr[AttributeDescriptor::COL_FORM_TYPE] == 'multiselect') {
             $valiMultisel = new Default_Form_Element_ValuelistMultiselect($attr[AttributeDescriptor::COL_ID], $attrName, array('label' => $attrLabel, 'required' => $required));
             $this->addElement($valiMultisel);
         } elseif ($attr[AttributeDescriptor::COL_FORM_TYPE] == 'multicheckbox') {
             $valiMulticheckbox = new Default_Form_Element_ValuelistMulticheckbox($attr[AttributeDescriptor::COL_ID], $attrName, array('label' => $attrLabel, 'required' => $required));
             $this->addElement($valiMulticheckbox);
         }
         //special link to remove search element for customized search filter
         if ($forImagesetAttribute) {
             if (!$fromValue) {
                 $formElem = $this->getElement($attrName);
                 $formElem->setDescription("<a href='/ce/edit/removeimagesetattribute/" . AttributeDescriptor::COL_ID . '/' . $attr[AttributeDescriptor::COL_ID] . "'>Remove attribute</a>")->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
             } else {
                 $subForm = $this->getSubForm($attrName);
                 $formElem = $subForm->getElement('fromValue');
                 $formElem->setDescription("<a href='/ce/edit/removeimagesetattribute/" . AttributeDescriptor::COL_ID . '/' . $attr[AttributeDescriptor::COL_ID] . "'>Remove attribute</a>")->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
             }
         }
         array_push($this->dynamicElements, $attrName);
         //            $this->addElement(	'submit',
         //									'Remove_attribute_ATDE_'.$attr[AttributeDescriptor::COL_ID],
         //									array(	'label' => 'Remove attribute',
         //            								'action' => '/ce/edit/removeimagesetattribute/'.AttributeDescriptor::COL_ID.'/'.$attr[AttributeDescriptor::COL_ID]));
     }
 }