Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UnitFieldset extends Fieldset implements ServiceLocatorAwareInterface
- {
- protected $serviceLocator;
- public function init()
- {
- $unitTable = $this->getFormFactory()
- ->getFormElementManager()
- ->getServiceLocator()
- ->get('Unit\Model\UnitTable')
- ->fetchAll() ;
- ;
- $this->setObject(new Unit())
- ->setHydrator(new ClassMethods());
- $selectData = array();
- foreach ( $unitTable as $selectOption ) {
- $selectData[ $selectOption->UnitID ] = $selectOption->UnitFullName;
- }
- $this->add([
- 'name' => 'srcUnit',
- 'type' => 'Select',
- 'options' => array(
- 'label' => ' Unit ',
- 'label_attributes' => array(
- 'class' => 'control-label text-left'
- ),
- 'value_options' => $selectData,
- ),
- 'attributes' => array(
- 'class' => 'form-control input-sm chosen-select-deselect chosen-select-width'
- )
- ]) ;
- return $this;
- }
- public function setServiceLocator(ServiceLocatorInterface $sl)
- {
- $this->serviceLocator = $sl;
- }
- public function getServiceLocator()
- {
- return $this->serviceLocator;
- }
- }
- ////MainForm
- $this->add(array(
- 'type' => 'Collection',
- 'name' => 'srcUnits',
- 'options' => array(
- 'label' => '',
- 'count' => 1,
- 'should_create_template' => true,
- 'allow_add' => true,
- 'use_as_base_fieldset' => false,
- 'create_new_objects' => true,
- 'target_element' => array('type' => 'UnitFieldset')
- ),
- ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement