CodeIgniter form_input syntax

#1
[eluser]sehummel[/eluser]
How do I do the equivalent of this in CI syntax?

Code:
<input id="password-field" type="text" name="password-field" title="Password">

Can't figure it out from the documentation. It's the onfocus parameter that seems to be screwing things up. I know I need to pass it an array, but this doesn't work:

Code:
<?php $pw = array('id' => 'password-field', 'name' => 'password', 'title' => 'Password', 'value' => 'Password', 'onfocus' => 'changefield();') ?>

<?php echo form_input('password', 'Password', $pw); ?>

Changefield is the name of my JS. It works when I do it the non-CI way.

#2
[eluser]Eric Barnes[/eluser]
I think you need:
Code:
<?php $js = 'onfocus = "changefield();"'; ?>
<?php echo form_input('password', 'Password', $js); ?>
or
<?php $pw = array('id' => 'password-field', 'name' => 'password', 'title' => 'Password', 'value' => 'Password', 'onfocus' => 'changefield();') ?>
<?php echo form_input($pw); ?>

#3
[eluser]cideveloper[/eluser]
Unobtrusive javascript with jquery

Code:
$data = array(
              'name'        => 'password-field',
              'id'          => 'password-field',
              'title'       => 'Password',
              'value'       => 'Password'
            );

echo form_input($data);

Jquery code

Code:
$(function(){

$('#password-field').focus(function() {
  //do changefield function here or call changefield function here
});

});


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.