protected function formDataEvent($tag, $callable = null)
    {
        $this->getEventManager()->attach(self::EVENT_FORM_DATA.$tag, function ($event) use ($callable) {
            $eventParams = $event->getParams();
            /* @var $form \Zend\Form\Form */
            $form = $eventParams['form'];
            /* @var $data Param */
            $data = $eventParams['data'];
            if (!empty($callable) && is_callable($callable)) {
                $data = call_user_func($callable, $data);
            }
            $form->setData($data->get());
        });
    }
protected function formDataEvent($tag, $callable = null)
    {
        $this->getEventManager()->attach(self::EVENT_FORM_DATA.$tag, function ($event) use ($callable) {
            $eventParams = $event->getParams();
            /* @var $form \Zend\Form\Form */
            $form = $eventParams['form'];
            /* @var $data Param */
            $data = $eventParams['data'];
            if (!empty($callable) && is_callable($callable)) {
                $data = call_user_func($callable, $data);
            }
            $form->setData($data->get());
        });
    }
protected function formDataEvent ( $ tag , $ callable = null ) { $ this -> getEventManager ( ) -> attach ( self :: EVENT_FORM_DATA . $ tag , function ( $ event ) use ( $ callable ) { $ eventParams = $ event -> getParams ( ) ; /* @var $form \Zend\Form\Form */ $ form = $ eventParams [ 'form' ] ; /* @var $data Param */ $ data = $ eventParams [ 'data' ] ; if ( ! empty ( $ callable ) && is_callable ( $ callable ) ) { $ data = call_user_func ( $ callable , $ data ) ; } $ form -> setData ( $ data -> get ( ) ) ; } ) ; }
Utility method for attaching a form data event listener
Utility method for attaching a form data event listener
for a form by a given tag. The optional 'callable' method
should accept and return a Param object.
@param $tag
@param null $callable
Utility method for attaching a form data event listener Utility method for attaching a form data event listener for a form by a given tag . The optional callable method should accept and return a Param object .