/**
  * Allows a user to view the list of locations type
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('add' => $this->_helper->hasAccess('add'), 'edit' => $this->_helper->hasAccess('edit'));
     $locationType = new LocationType();
     $locationTypes = $locationType->fetchAll(null, 'name');
     $this->view->locationTypes = $locationTypes;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->_helper->pageTitle('workshop-location-type-index:Title');
 }
Exemplo n.º 2
0
 /**
  * Gets the form for adding and editing a location
  *
  * @param array $values
  * @return Zend_Form
  */
 public function form($values = array())
 {
     $form = new Zend_Form();
     $form->setAttrib('id', 'locationForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form'));
     $name = $form->createElement('text', 'name', array('label' => 'Name:'));
     $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setValue(isset($values['name']) ? $values['name'] : '');
     $status = $form->createElement('select', 'status', array('label' => 'Status:'));
     $status->addMultiOption('enabled', 'Enabled');
     $status->addMultiOption('disabled', 'Disabled');
     $status->setValue(isset($values['status']) ? $values['status'] : 'enabled');
     $locationType = new LocationType();
     $types = $locationType->fetchAll(null, 'name');
     $type = $form->createElement('select', 'locationType', array('label' => 'Location Type:'));
     foreach ($types as $t) {
         $type->addMultiOption($t->typeId, $t->name);
     }
     $type->setRequired(true)->setValue(isset($values['locationType']) ? $values['locationType'] : '');
     $capacity = $form->createElement('text', 'capacity', array('label' => 'Capacity:'));
     $capacity->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->addValidator('Digits')->setAttrib('maxlength', '64')->setValue(isset($values['capacity']) ? $values['capacity'] : '');
     $address = $form->createElement('text', 'address', array('label' => 'Address:'));
     $address->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['address']) ? $values['address'] : '');
     $description = $form->createElement('textarea', 'description', array('label' => 'Description:'));
     $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 300px;')->setValue(isset($values['description']) ? $values['description'] : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel'));
     $cancel->setAttrib('id', 'cancel');
     $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton'))));
     $form->addElements(array($name, $status, $type, $capacity, $address, $description));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel));
     if (isset($values['locationId'])) {
         $locationId = $form->createElement('hidden', 'locationId');
         $locationId->setValue($values['locationId']);
         $locationId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
         $form->addElement($locationId);
     }
     return $form;
 }