1

i create form search using codeigniter's form_helper

<?php echo form_open(site_url( 'lab/hasil_rawat_jalan'), array( 'method'=>'get')) ?>
<div class="form-group">
  <label class="sr-only" for="value">Search</label>
  <?php echo form_input( 'value', $this->input->get('value'), 'type="text" class="form-control" id="value" placeholder="Search..."') ?>
</div>
<input class="btn btn-default btn-sm" type="submit" value="Go">
</form>

the problem is if i change

<?php echo form_input( 'value', $this->input->get('value'), 'type="text" class="form-control" id="value" placeholder="Search..."') ?>

into this(which mean normal input tag)

<input type="text" class="form-control" id="value" placeholder="Search..." value="<?php echo $this->input->get('value');?>">

I can not get any value in my url, do I miss something here?

if you do not understand my question please ask. thanks^^

4
  • The advantage of using the functions of the Form helper instead of generating pure HTML is just that it's less problematic create the form dynamically and you just pass an array instead of concatenating strings. Commented Oct 16, 2015 at 4:08
  • @AnmolRaghuvanshi , what i supposed to do? i use form helper because i cant use regular html input tag. Commented Oct 16, 2015 at 4:11
  • Do you assign any values into data variable inside relevant controller method? Commented Oct 16, 2015 at 4:12
  • @NorlihazmeyGhazali I did not Commented Oct 16, 2015 at 4:14

2 Answers 2

3

If you want the value, please add name attribute.

<input name="value" type="text" class="form-control" id="value" placeholder="Search..." value="<?php echo $this->input->get('value');?>" >
       ^          ^

In code igniter, first parameter in the name of the text box.

<?php echo form_input( 'value', $this->input->get('value'), 'type="text" class="form-control" id="value" placeholder="Search..."') ?>
                       ^      ^
Sign up to request clarification or add additional context in comments.

2 Comments

OMG!, what a shame to have this problem asked in stackoverflow T T . thanks dude
Its not shame bro, it happens,. Glad it helped you:)
0

Here means that create and input text with value name with $this->input->get('value') this value:

 form_input( 'value', $this->input->get('value')...)

But in your case value become attribute, not the name of name attribute:

<input type="text" class="form-control" id="value" placeholder="Search..." value="<?php echo $this->input->get('value');?>">

1 Comment

You got it @Niranjan N Raju ;)

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.