Welcome Guest, Not a member yet? Register   Sign In
Form button helper

[eluser]Daryl W[/eluser]
I am trying to use the form button helper "form_button()" to build a button that will link back to the controller like this:

<?php $data = array(
'name' => 'button',
'class' => 'button1',
'content' => 'Signup',
'onclick' => anchor('login/signup')
<?php echo form_button($data);?>

Which does not return the href correctly. for form_button helper interprates the first comma in the anchor helper as the end of the onclick parameter.

I can get this to work but it bypasses the controller:

<?php echo form_button('button','Signup','onclick="location.href=\'http://localhost/ds_con/login/signup\'"');?>

just not the button built with the data array.

Many thanks,


Using the anchor here is wrong. The anchor function creates a html link! Including the <a > around it. That is not something you can put in a javascript onclick property.
I don't see why you couldn't put the string 'location.href ...' inside your $data = ... array. That would do it. It's not the form_button helper that is your problem, but the anchor helper.

[eluser]Daryl W[/eluser]
Hi Grad Student,

I ended up putting the3 location.href... inside the $data array and it worked fine.

Thanks for your help

Theme © iAndrew 2016 - Forum software by © MyBB