Professional CodeIgniter, Thomas Myer

Chapter 3: A 10,000 - Foot View of CodeIgniter
63

Finally, you create a Submit button with
form_submit()

, and close a form with
form_close()
,
like this:
echo form_submit(`submit', `search');
echo form_close();

Thus your entire search form looks like
echo form_open(`welcome/search');
echo form_hidden(`id', `414');
echo form_hidden(`searchtype', `basic');
$data = array(
`name' =
>
`searchterm',
`id' =
>
`search',
`maxlength' =
>
`100',
`size' =
>
`50',
`style' =
>
`background-color:#f1f1f1'
)
echo form_input($data);
$values = array(
`high' =
>
`high',
`medium' =
>
`medium',
`low' =
>
`low'
);
echo form_dropdown(`priority', $values, `medium');
echo form_submit(`submit', `search');
echo form_close();


The URL Helper

Another extremely useful helper is the URL helper . You will often be using three functions from this
helper:
base_url()
,
anchor()

, and
redirect()
.
The
base_url()

function prints out the base URL configuration setting that you placed in the /system/
application/config/config.php file. Its chief virtue is that it allows you to create more portable code. For
example, if you need to reference an image in the root directory of the server, you can use
base_url()

to make sure that image is always found:
echo base_url() . `/images/logo.jpg';

Similarly useful, the
anchor()

function helps you create links that are portable from one environment to
another. For example, to create a link to a contact_us page, you would simply pass two arguments to the
anchor()

function: the URI followed by the link text.
echo anchor(`welcome/contact_us', `Contact Us Today!');
c03.indd 63
c03.indd 63
6/10/08 5:33:51 PM
6/10/08 5:33:51 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.