Need help on a Form Button Click
- kc2scy
- Member | 22
Hello,
I have a form that has two buttons one is to submit the form which works
just find.
The second button I'd like to setup to jump to another page that lets the user
register.
So what I tried so far as a test :
(the below code did not work :-) )
$form->addButton('home','Home!')
->setAttribute('onclick','n:href="Homepage:');
any help would be great.
Mike
Last edited by kc2scy (2014-01-30 06:07)
- kc2scy
- Member | 22
Hello Honos,
Ok I tried:
$form->addButton('home','Home!')
->getElementPrototype()
->onclick = 'javascript:window.location.href="'.$this->link("Homepage:').'"';
and I get this error:
Call to undefined method Nette\Forms\Controls\Button::getElementPrototype()
then I tried this one:
$form->addButton('home','Home!')
->setAttribute('onclick','javascript:window.location.href="'.$this->link('Homepage:').'"');
and I get this error:
Object of class Nette\Forms\Controls\Button could not be converted to int
I'm not sure if I'm concatenate the string correctly or nor not.
Thanks for your help.
- kc2scy
- Member | 22
Hi Honos,
i went back and made sure the stirng was being built correctly. and looked
like I had one to many quotes.
so this one worked for me:
$form->addButton('home','Home!')
->setAttribute('onclick','javascript:window.location.href="'.$this->link('Homepage:').'"');
Thank you for taking the time to show me this..
Again thanks.
Mike
- honos
- Member | 109
OK, its wrong:
$form->addButton('home','Home!')
->getElementPrototype()
->onclick = 'javascript:window.location.href="'.$this->link("Homepage:').'"';
right is
$form->addButton('home','Home!')
->getControlPrototype()
->onclick = 'javascript:window.location.href="'.$this->link("Homepage:').'"';
Just smile :) Sorry for my english…
- kc2scy
- Member | 22
honos wrote:
OK, its wrong:
$form->addButton('home','Home!') ->getElementPrototype() ->onclick = 'javascript:window.location.href="'.$this->link("Homepage:').'"';
right is
$form->addButton('home','Home!') ->getControlPrototype() ->onclick = 'javascript:window.location.href="'.$this->link("Homepage:').'"';
Just smile :) Sorry for my english…
Np :-) your English is better than mine!