Author: David Grudl
Inheritance: extends BaseControl
Exemple #1
0
	/**
	 * This method will be called when the component (or component's parent)
	 * becomes attached to a monitored object. Do not call this method yourself.
	 * @param  Nette\ComponentModel\IComponent
	 * @return void
	 */
	protected function attached($presenter)
	{
		if ($presenter instanceof Presenter) {
			$name = $this->lookupPath('Nette\Application\UI\Presenter');

			if (!isset($this->getElementPrototype()->id)) {
				$this->getElementPrototype()->id = 'frm-' . $name;
			}

			if (iterator_count($this->getControls()) && $this->isSubmitted()) {
				foreach ($this->getControls() as $control) {
					if (!$control->isDisabled()) {
						$control->loadHttpData();
					}
				}
			}

			if (!$this->getAction()) {
				$this->setAction(new Link($presenter, 'this', array()));
				$signal = new Nette\Forms\Controls\HiddenField($name . self::NAME_SEPARATOR . 'submit');
				$signal->setOmitted()->setHtmlId(FALSE);
				$this[Presenter::SIGNAL_KEY] = $signal;
			}
		}
		parent::attached($presenter);
	}
Exemple #2
0
 /**
  * Form constructor.
  * @param  string
  */
 public function __construct($name = NULL)
 {
     if ($name !== NULL) {
         $this->getElementPrototype()->id = 'frm-' . $name;
         $tracker = new Controls\HiddenField($name);
         $tracker->setOmitted();
         $this[self::TRACKER_ID] = $tracker;
     }
     parent::__construct(NULL, $name);
 }
Exemple #3
0
 /**
  * Form constructor.
  * @param  string
  */
 public function __construct($name = NULL)
 {
     $this->element = Nette\Utils\Html::el('form');
     $this->element->action = '';
     // RFC 1808 -> empty uri means 'this'
     $this->element->method = self::POST;
     $this->element->id = $name === NULL ? NULL : 'frm-' . $name;
     $this->monitor(__CLASS__);
     if ($name !== NULL) {
         $tracker = new Controls\HiddenField($name);
         $tracker->unmonitor(__CLASS__);
         $this[self::TRACKER_ID] = $tracker;
     }
     parent::__construct(NULL, $name);
 }
 /**
  * Adds hidden form control used to store a non-displayed value.
  * @param  string  control name
  * @param  mixed   default value
  * @return Nette\Forms\Controls\HiddenField
  */
 public function addHidden($name, $default = NULL)
 {
     $control = new Controls\HiddenField();
     $control->setDefaultValue($default);
     return $this[$name] = $control;
 }
Exemple #5
0
 /**
  * Generates control's HTML element.
  *
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     return parent::getControl()->value($this->getToken());
 }
 /**
  * @param CaptchaProvider $provider
  */
 public function __construct(CaptchaProvider $provider)
 {
     parent::__construct($provider->getHash());
     $this->provider = $provider;
 }
Exemple #7
0
 /**
  * @param string|null $caption
  */
 public function __construct($caption = null)
 {
     parent::__construct($caption);
     $this->monitor('Nette\\Application\\UI\\Presenter');
     $this->setOmitted(true);
 }