public function __construct($event, $onEvent, $onSubmit, $onError)
 {
     Args::callBackArgs($onEvent, 1, 'onEvent');
     if ($onSubmit != null) {
         Args::callBackArgs($onSubmit, 1, 'onSubmit');
     }
     if ($onError != null) {
         Args::callBackArgs($onError, 1, 'onError');
     }
     $self = $this;
     parent::__construct($event, function ($target) use($self, $onEvent, $onSubmit, $onError) {
         $formComponent = $self->getComponent();
         $formComponent->processInput();
         $onEvent($target);
         if ($formComponent->isValid() && $onSubmit != null) {
             $onSubmit($target);
         }
         if (!$formComponent->isValid() && $onError != null) {
             $onError($target);
         }
     });
 }
 public function __construct($event, $onSubmit = null, $onError = null, $form = null)
 {
     $self = $this;
     parent::__construct($event, function ($target) use($self) {
         $self->setAjaxRequestTarget($target);
         $self->getForm()->process($self);
     });
     if ($onSubmit != null) {
         Args::callBackArgs($onSubmit, 1, 'onSubmit');
     }
     if ($onError != null) {
         Args::callBackArgs($onError, 1, 'onError');
     }
     $this->onSubmit = $onSubmit;
     $this->onError = $onError;
     if ($form != null) {
         if ($form instanceof Form) {
             $this->form = $form;
         } else {
             throw new \InvalidArgumentException('$form must be an instance of Form');
         }
     }
 }