public function startForm($p_id) { $baseUrl = Application_Common_OsPath::getBaseDir(); // Set the method for the display form to POST $this->setMethod('post'); $this->addElement('hidden', 'file_id', array('value' => $p_id)); // Add title field $this->addElement('text', 'track_title', array('label' => _('Title:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add artist field $this->addElement('text', 'artist_name', array('label' => _('Creator:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add album field $this->addElement('text', 'album_title', array('label' => _('Album:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add track number field $this->addElement('text', 'track_number', array('label' => _('Track:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add genre field $this->addElement('text', 'genre', array('label' => _('Genre:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add year field $year = new Zend_Form_Element_Text('year'); $year->class = 'input_text'; $year->setLabel(_('Year:'))->setFilters(array('StringTrim'))->setValidators(array(new Zend_Validate_StringLength(array('max' => 10)), Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM-DD"), Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM"), Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY"))); $this->addElement($year); // Add label field $this->addElement('text', 'label', array('label' => _('Label:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add composer field $this->addElement('text', 'composer', array('label' => _('Composer:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add conductor field $this->addElement('text', 'conductor', array('label' => _('Conductor:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add mood field $this->addElement('text', 'mood', array('label' => _('Mood:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add bmp field $bpm = new Zend_Form_Element_Text('bpm'); $bpm->class = 'input_text'; $bpm->setLabel(_('BPM:'))->setFilters(array('StringTrim'))->setValidators(array(new Zend_Validate_StringLength(array('min' => 0, 'max' => 8)), new Zend_Validate_Digits())); $this->addElement($bpm); // Add copyright field $this->addElement('text', 'copyright', array('label' => _('Copyright:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add isrc number field $this->addElement('text', 'isrc_number', array('label' => _('ISRC Number:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add website field $this->addElement('text', 'info_url', array('label' => _('Website:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add language field $this->addElement('text', 'language', array('label' => _('Language:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add the submit button $this->addElement('button', 'editmdsave', array('ignore' => true, 'class' => 'btn', 'label' => _('Save'), 'decorators' => array('ViewHelper'))); // Add the submit button $this->addElement('button', 'editmdcancel', array('ignore' => true, 'class' => 'btn md-cancel', 'label' => _('Cancel'), 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('editmdsave', 'editmdcancel'), 'submitButtons', array('decorators' => array('FormElements', 'DtDdWrapper'))); }
public function init() { $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/add-show-when.phtml')))); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $dateValidator = Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM-DD"); $regexValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator("/^[0-2]?[0-9]:[0-5][0-9]\$/", _("'%value%' does not fit the time format 'HH:mm'")); // Add start date element $startDate = new Zend_Form_Element_Text('add_show_start_date'); $startDate->class = 'input_text'; $startDate->setRequired(true)->setLabel(_('Date/Time Start:'))->setValue(date("Y-m-d"))->setFilters(array('StringTrim'))->setValidators(array($notEmptyValidator, $dateValidator))->setDecorators(array('ViewHelper')); $startDate->setAttrib('alt', 'date'); $this->addElement($startDate); // Add start time element $startTime = new Zend_Form_Element_Text('add_show_start_time'); $startTime->class = 'input_text'; $startTime->setRequired(true)->setValue('00:00')->setFilters(array('StringTrim'))->setValidators(array($notEmptyValidator, $regexValidator))->setDecorators(array('ViewHelper')); $startTime->setAttrib('alt', 'time'); $this->addElement($startTime); // Add end date element $endDate = new Zend_Form_Element_Text('add_show_end_date_no_repeat'); $endDate->class = 'input_text'; $endDate->setRequired(true)->setLabel(_('Date/Time End:'))->setValue(date("Y-m-d"))->setFilters(array('StringTrim'))->setValidators(array($notEmptyValidator, $dateValidator))->setDecorators(array('ViewHelper')); $endDate->setAttrib('alt', 'date'); $this->addElement($endDate); // Add end time element $endTime = new Zend_Form_Element_Text('add_show_end_time'); $endTime->class = 'input_text'; $endTime->setRequired(true)->setValue('01:00')->setFilters(array('StringTrim'))->setValidators(array($notEmptyValidator, $regexValidator))->setDecorators(array('ViewHelper')); $endTime->setAttrib('alt', 'time'); $this->addElement($endTime); // Add duration element $this->addElement('text', 'add_show_duration', array('label' => _('Duration:'), 'class' => 'input_text', 'value' => '01h 00m', 'readonly' => true, 'decorators' => array('ViewHelper'))); $timezone = new Zend_Form_Element_Select('add_show_timezone'); $timezone->setRequired(true)->setLabel(_("Timezone:"))->setMultiOptions(Application_Common_Timezone::getTimezones())->setValue(Application_Model_Preference::GetUserTimezone())->setAttrib('class', 'input_select add_show_input_select')->setDecorators(array('ViewHelper')); $this->addElement($timezone); // Add repeats element $this->addElement('checkbox', 'add_show_repeats', array('label' => _('Repeats?'), 'required' => false, 'decorators' => array('ViewHelper'))); }