0

How could be possible something like this:

The standard of form syntax is:

<?php echo form_open('controller_name/function_name');?>

But I have came to moment when I need to make form controller function with argument which would look something like this:

<?php echo form_open('controller_name/function_name(argument_name)');?>

I searched on google but I couldn't find any solutions for this. Any ideas?

3 Answers 3

3

I would suggest you put those arguments into hidden fields:

Adding Hidden Input Fields

Hidden fields can be added by passing an associative array to the third parameter, like this:

$hidden = array('username' => 'Joe', 'member_id' => '234');

echo form_open('email/send', '', $hidden);

The above example would create a form similar to this:

<form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send">
<input type="hidden" name="username" value="Joe" />
<input type="hidden" name="member_id" value="234" />

Source: http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

Sign up to request clarification or add additional context in comments.

Comments

0

I think you mean this?

echo form_open($form_action, $attributes); 

If not, please clarify what you mean with arguments?

Comments

0

you could do this

<?php
 echo form_open('controller_name/function_name/{$arg_1}/{$arg_2}')
?>

and your controller as usual will have the

  class controller_name extends CI_Controller {
     function function_name($arg_i, $arg_2) {
        //function content
     }
  }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.