Registracia vlastneho formularoveho prvku problem s form kontainerom
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- duskohu
- Člen | 778
Caute, neviete mi poradit? Urobil som si form. prvok a zaregistroval v bootstrape, vsetko funguje fajn ale ked pouzijem kontainer tak na mna ladenka vybehne ze Call to undefined method Nette\Forms\Container::addSuggestionInput(), neviete mi poradit co mam zle?
namespace Nette\Forms\Controls;
class SuggestionInput extends TextInput implements ISignalReceiver {
.....
public static function register() {
Form::extensionMethod('addSuggestionInput', callback(__CLASS__, 'addSuggestionInput'));
}
public static function addSuggestionInput(Form $form, $name, $label = NULL) {
$form[$name] = new self($label);
return $form[$name];
}
}
v bootstrap:
Nette\Forms\Controls\SuggestionInput::register();
formular:
$form = new Form;
$form->addSuggestionInput("mesto", "Mesto");
ale ked pouzijem uz toto, tak mi vypise ze Call to undefined method Nette\Forms\Container::addSuggestionInput()
$form = new Form;
$companyAddress = $form->addContainer('companyAddress');
$companyAddress ->addSuggestionInput("mesto", "Mesto");
Editoval duskohu (18. 1. 2013 10:52)
- duskohu
- Člen | 778
Ocividne nemam tento prvok v Nette\Forms\Container takze to zaregistrujem, ale nedalo by sa to jednou registraciou?
public static function register() {
Form::extensionMethod('addSuggestionInput', callback(__CLASS__, 'addSuggestionInput'));
\Nette\Forms\Container::extensionMethod('addSuggestionInput', callback(__CLASS__, 'addSuggestionInput'));
}
public static function addSuggestionInput( $form, $name, $label = NULL) {
$form[$name] = new self($label);
return $form[$name];
}