Link to

From PHP on Trax

Jump to: navigation, search

link_to( string $name, array/string $options, [array $html_options] )

Description

Creates a link tag of the given name using an URL created by the set of options. See the valid options in the documentation for url_for. It’s also possible to pass a string instead of an options hash to get a link tag that just points without consideration. If nil is passed as a name, the link itself will become the name. The html_options has three special features. One for creating javascript confirm alerts where if you pass :confirm => ‘Are you sure?’, the link will be guarded with a JS popup asking that question. If the user accepts, the link is processed, otherwise not.

$name the name of the link

$options - if a string will directly use the string for the href. If an array, needs to be an associatative array.

$html_options - options to go into the anchor tag

Examples



<?= link_to("Delete this page", array(":action" => "delete"":id" => $page->id), array("confirm" => "Are you sure?")) ?>
<?= link_to
("Yahoo!""http://www.yahoo.com", array("style" => "bigLink")) ?>
<?= link_to
("Edit", array(":action" => "edit"":id" => $user)) ?>
Personal tools