Skip to content

Commit

Permalink
added options in forms
Browse files Browse the repository at this point in the history
  • Loading branch information
kokspflanze committed May 2, 2015
1 parent 365c22b commit 290d044
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 65 deletions.
120 changes: 61 additions & 59 deletions src/ZfcTicketSystem/Form/TicketSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,75 @@

namespace ZfcTicketSystem\Form;

use Zend\ServiceManager\ServiceManager;
use Zend\Form\Form;
use Zend\Form\Element;
use ZfcBase\Form\ProvidesEventsForm;
use Doctrine\ORM\EntityManager;

class TicketSystem extends ProvidesEventsForm
{

public function __construct( EntityManager $entityManager )
/**
* @param ServiceManager $serviceLocator
*/
public function __construct( ServiceManager $serviceLocator )
{
parent::__construct();
$this->add(array(
'type' => 'Zend\Form\Element\Csrf',
'name' => 'fdh456eh56ujzum45zkuik45zhrh'
));
parent::__construct();
$this->add(array(
'type' => 'Zend\Form\Element\Csrf',
'name' => 'fdh456eh56ujzum45zkuik45zhrh'
));

$this->add(array(
'name' => 'subject',
'options' => array(
'label' => 'Subject',
),
'attributes' => array(
'placeholder' => 'Subject',
'class' => 'form-control',
'type' => 'text'
),
));
$this->add(array(
'name' => 'categoryId',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'object_manager'=> $entityManager,
'target_class' => 'ZfcTicketSystem\Entity\TicketCategory',
'property' => 'subject',
'label' => 'Category',
'empty_option' => '-- select --',
'is_method' => true,
'find_method' => array(
'name' => 'getActiveCategory',
),
),
'attributes' => array(
'class' => 'form-control',
),
));
$this->add(array(
'name' => 'memo',
'type' => 'Zend\Form\Element\Textarea',
'options' => array(
'label' => 'Memo',
),
'attributes' => array(
'placeholder' => 'Memo',
'class' => 'form-control',
),
));
$this->add(array(
'name' => 'subject',
'options' => array(
'label' => 'Subject',
),
'attributes' => array(
'placeholder' => 'Subject',
'class' => 'form-control',
'type' => 'text'
),
));
$this->add(array(
'name' => 'categoryId',
'type' => 'DoctrineModule\Form\Element\ObjectSelect',
'options' => array(
'object_manager'=> $serviceLocator->get( 'Doctrine\ORM\EntityManager' ),
'target_class' => $serviceLocator->get( 'zfcticketsystem_entry_options' )->getTicketCategory(),
'property' => 'subject',
'label' => 'Category',
'empty_option' => '-- select --',
'is_method' => true,
'find_method' => array(
'name' => 'getActiveCategory',
),
),
'attributes' => array(
'class' => 'form-control',
),
));
$this->add(array(
'name' => 'memo',
'type' => 'Zend\Form\Element\Textarea',
'options' => array(
'label' => 'Memo',
),
'attributes' => array(
'placeholder' => 'Memo',
'class' => 'form-control',
),
));

$submitElement = new Element\Button('submit');
$submitElement
->setLabel('Submit')
->setAttributes(array(
'class' => 'btn btn-primary',
'type' => 'submit',
));
$submitElement = new Element\Button('submit');
$submitElement
->setLabel('Submit')
->setAttributes(array(
'class' => 'btn btn-primary',
'type' => 'submit',
));

$this->add($submitElement, array(
'priority' => -100,
));
}
$this->add($submitElement, array(
'priority' => -100,
));
}
}
13 changes: 8 additions & 5 deletions src/ZfcTicketSystem/Form/TicketSystemFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public function __construct( ServiceManager $serviceManager )
}

/**
* @param ServiceManager $oServiceManager
*
* @param ServiceManager $serviceManager
* @return $this
*/
public function setServiceManager( ServiceManager $oServiceManager )
public function setServiceManager( ServiceManager $serviceManager )
{
$this->serviceManager = $oServiceManager;
$this->serviceManager = $serviceManager;

return $this;
}
Expand All @@ -81,7 +81,10 @@ public function setServiceManager( ServiceManager $oServiceManager )
protected function getTicketCategory()
{
/** @var \ZfcTicketSystem\Entity\Repository\TicketCategory $ticketCategory */
$ticketCategory = $this->getEntityManager()->getRepository('ZfcTicketSystem\Entity\TicketCategory');
$ticketCategory = $this->getEntityManager()->getRepository(
$this->getServiceManager()->get( 'zfcticketsystem_entry_options' )->getTicketCategory()
);

$category = $ticketCategory->getActiveCategory();

$result = array();
Expand Down
2 changes: 1 addition & 1 deletion src/ZfcTicketSystem/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getServiceConfig()
'factories' => array(
'zfcticketsystem_ticketsystem_new_form' => function ( $sm ) {
/** @var $sm \Zend\ServiceManager\ServiceLocatorInterface */
$form = new Form\TicketSystem( $sm->get( 'Doctrine\ORM\EntityManager' ) );
$form = new Form\TicketSystem( $sm );
$form->setInputFilter( new Form\TicketSystemFilter( $sm ) );
return $form;
},
Expand Down

0 comments on commit 290d044

Please sign in to comment.