Nette 0.9.4 ae0c8bd ma prazdne hodnoty v prvcich formulare po odeslani

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
scarabeus_iv
Člen | 2
+
0
-

Po upgradu z nette 0.8.6 na vise uvedenou verzi mam pri zpracovani tyto hodnoty.
Prvni pole je $form->getValues(); a druhe je $_POST;

array(2) {
   "perforAction" => string(6) "remove"
   "id_menu" => string(0) ""
}

array(4) {
   "btn_ok" => string(8) "Potvrdit"
   "_token_" => string(32) "66a384018bcafa1785e5f4c4ea866f56"
   "perforAction" => string(6) "remove"
   "id_menu" => string(1) "3"
}

Kod presenteru je celkem jednoduchy:

class MenuControlPresenter extends DefaultPresenter {
	const FORM_CONFIRM = 'menu_confirm';
	const FORM_CONFIRM_DELETE = 'menu_confirm_remove';
	const ACTION_DELETE = 'remove';
	var $menuID = NULL;

	public function renderResult($performAction = 'none') {
		$this->template->title = 'Menu - Výsledek operace';

		switch ($performAction) {
			case self::ACTION_DELETE:
				$this->template->result = 'Menu smazáno';
				break;
		}
	}

	public function renderConfirm($performAction = 'none' , $menuID = NULL) {
		$this->template->title = 'Menu - Potvrzení';

		switch ($performAction) {
			case self::ACTION_DELETE:
				$this->template->confirmText = 'Opravdu chcete smazat vybrané menu a všechna jeho podmenu?';
				$this->menuID = $menuID;
				$this->template->form = $this->getComponent(self::FORM_CONFIRM_DELETE);
				break;
		}
	}

	public function initConfirmSubmitted(AppForm $form) {
		$oMenu = Menu::getInstance();

		if (!$form['btn_cancel']->isSubmittedBy()) {
			$performAction = isset($form['performAction']) ? $form['performAction']->getValue() : NULL;

			switch ($performAction) {
				case self::ACTION_DELETE:
					// delete the menu
					$oMenu->menu_delete($form['id_menu']->getValue());
					break;
			}
			$this->redirect('MenuControl:Result',  array('performAction' => $performAction));
		} else {
			$this->redirectEvent();
		}
	}

	public function createComponent($componentName) {
		switch ($componentName) {
			case self::FORM_CONFIRM_DELETE:
				$this->_createDeleteConfirmForm();
				break;
			default:
				parent::createComponent($componentName);
				break;
		}
	}

	private function _createMenuConfirmForm($name = self::FORM_CONFIRM) {
		$form = new AppForm($this, $name);
		$form->onSubmit[] = callback($this, 'initConfirmSubmitted');

		$htmlForm = $form->getElementPrototype();
		$htmlForm->id = 'form_confirm';
		$htmlForm->class = 'form_confirm';

		$form->addSubmit('btn_ok', 'Potvrdit');

		$form->addSubmit('btn_cancel', 'Zrušit')
			->setValidationScope(FALSE); // nebude se nic validovat
		$form->addProtection();

		return $form;
	}

	private function _createDeleteConfirmForm() {
		$this->_createMenuConfirmForm(self::FORM_CONFIRM_DELETE);

		$form = $this->getComponent(self::FORM_CONFIRM_DELETE);

		$htmlForm = $form->getElementPrototype();
		$htmlForm->id = 'form_confirm_delete';

		$form->addHidden('performAction')->setValue(self::ACTION_DELETE);
		$form->addHidden('id_menu')->setValue($this->menuID);

		return $form;
	}
}

Neprozradil by mi nekdo co musim udelat aby mi formularova data chodila zase spravne? :]

scarabeus_iv
Člen | 2
+
0
-

Ok, jak uchvatne, clovek to resi 4 hodiny a prepisuje to vsemozne, aby nakonec prisel na to ze staci pouzivat setDefaultValue misto setValue :]

Anyway pokud nekdo narazi na stejnej problem tak tohle je celkem pekne reseni :P