How to pass the value of a variable through the form_open codeigniter function?

Asked

Viewed 139 times

0

Good evening Using codeigniter how do I pass the value of a variable through the form_open() function? because here I have to inform the controller and the method that will be responsible for the execution of the form, I know that without codeigniter it is possible to pass the variables by parameter through the form action.

1 answer

1


You can pass the method directly:

echo form_open('email/send');

Ci’s gonna tag it

<form method="post" accept-charset="utf-8" action="http://example.com/index.php/email/send">

You can also pass attributes in the form of Array:

    $attributes = array('class' => 'email', 'id' => 'myform');
    echo form_open('email/send', $attributes);

Or directly as a string:

echo form_open('email/send', 'class="email" id="myform"');

The two ways will generate the tag:

<form method="post" accept-charset="utf-8" action="http://example.com/index.php/email/send" class="email" id="myform">
  • Thanks worked out here thanks for the tips, had not found on the internet a better definition than yours.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.