Пример #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);
	}
Пример #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);
 }
 /**
  * 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->setOmitted();
         $this[self::TRACKER_ID] = $tracker;
     }
     parent::__construct(NULL, $name);
 }