示例#1
0
 /**
  * Setter for the default pad, to be pre-selected in the pad select form element.
  *
  * @param Pad|null $pad
  */
 public function setPad(Pad $pad = NULL)
 {
     if ($pad === NULL) {
         return;
         // ignore
     }
     $this['form']->setDefaults(['pad' => $pad->getId()]);
 }
示例#2
0
 /**
  * Factory method for subcomponent form instance.
  * This factory is called internally by Nette in the component model.
  *
  * This factory creates a PadsControl that handles edit of existing pads.
  *
  * @return \Notejam\Components\PadsControl
  * @throws Nette\Application\BadRequestException
  */
 protected function createComponentEditPad()
 {
     if ($this->action !== 'edit' || !$this->pad) {
         $this->error();
     }
     $control = $this->padsControlFactory->create();
     $control->setPad($this->pad);
     $control->onSuccess[] = function () {
         $this->flashMessage('Pad has been edited', 'success');
         $this->redirect('Pad:detail', ['id' => $this->pad->getId()]);
     };
     return $control;
 }