CodeIgniter form helper

CodeIgniter form example:

<?php echo form_open( base_url() . 'users/register' ); ?>
 
<?php echo form_label( 'Username', 'username' ); ?>
 
<?php
$input_attributes = array(
	'name' => 'username',
	'id' => 'username',
	'value' => set_value( 'username', 'default_username' ),
	'maxlength'   => '100',
	'class' => 'text_input'
);
echo form_input( $input_attributes );
?>
 
<?php
$textarea_attributes = array(
	'name' => 'message',
	'id' => 'message',
	'value' => set_value( 'message', 'default_message' ),
	'class' => 'textarea_input'
);
echo form_textarea( $textarea_attributes );
?>
 
<?php 
$role_options = array(
	'' => '---',
	'admin' => 'admin',
	'author' => 'author',
	'user' => 'user'
); 
echo form_dropdown( 'role', $role_options, set_value( 'role', 'admin' ), 'id="role"' );
?>
 
<?php echo form_submit( '', 'register' ); ?>
 
<?php form_hidden( 'user_id', '777' ); ?>
 
<?php echo form_close(); ?>

CodeIgniter multipart form example:

<?php echo form_open_multipart( base_url() . 'upload/do_upload' ); ?>
 
<?php
$upload_attributes = array(
	'name' => 'userfile'
);
echo form_upload( $upload_attributes ); ?>
 
<?php echo form_submit( '', 'upload' ); ?>
 
<?php echo form_close(); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *