CodeIgniter Forums
question on how can I disable form_input area? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: question on how can I disable form_input area? (/showthread.php?tid=54555)



question on how can I disable form_input area? - El Forum - 09-13-2012

[eluser]Nano HE[/eluser]
Hello.

How can I do this?
I want only disable one input area in my form.
And show some alert contents in the disabled form instead.

Code:
$data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'size'        => '25',
              //'style'       => 'width:20%',
            );

    echo form_input($data);

and the webpage viwed like this,
Like this: [Disabled Search for Traffic Limitation]





question on how can I disable form_input area? - El Forum - 09-13-2012

[eluser]CroNiX[/eluser]
Did you try adding
'disabled' => TRUE?


question on how can I disable form_input area? - El Forum - 09-13-2012

[eluser]TWP Marketing[/eluser]
[quote author="Nano HE" date="1347580582"]Hello.

How can I do this?
I want only disable one input area in my form.
And show some alert contents in the disabled form instead.

Code:
$data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'size'        => '25',
              //'style'       => 'width:20%',
            );
if( ! $disable )
{
    echo form_input($data);
}else{
echo ' [Disabled Search for Traffic Limitation]';
}

and the webpage viwed like this,
Like this: [Disabled Search for Traffic Limitation]
[/quote]
You will need to pass the flag: $disable from your controller as a boolean true/false


question on how can I disable form_input area? - El Forum - 09-13-2012

[eluser]PhilTem[/eluser]
As CroNiX said you need to set the disabled attribute, however not in the way he said sine this is considered not RFC compliant, so use

Code:
$data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'disabled'    => 'disabled'
              'size'        => '25',
              //'style'       => 'width:20%',
            );

echo form_input($data);

which will create a form input that can not be edited though (and by the way won't be submitted when the form is submitted Wink )


question on how can I disable form_input area? - El Forum - 09-13-2012

[eluser]CroNiX[/eluser]
@philTem, did you look at the html that using 'disabled' => TRUE produces? It's the same.
Code:
<input type="text" size="25" disabled="disabled" maxlength="100" id="searchform" value="" name="keyword">



question on how can I disable form_input area? - El Forum - 09-14-2012

[eluser]PhilTem[/eluser]
Oh really, it does produce disabled="disabled"? I didn't know that. But I guess that's the point of forums: You never stop learning new stuff Wink Thanks, @CroNiX


question on how can I disable form_input area? - El Forum - 09-15-2012

[eluser]Nano HE[/eluser]
Code:
echo form_open($formSearchOpenUrl, $attributes);
    $data = array(
              'name'        => 'keyword',
              'id'          => 'searchform',
              'value'       => '',
              'maxlength'   => '100',
              'size'        => '25',
              //'style'       => 'width:20%',
     // 'disabled' => TRUE, // Worked!
     'disabled' => 'disabled',   // Also worked!

     'value'   => 'Disabled for Traffic Limitation'
            );

    echo form_input($data);

    echo form_submit('mysearchsubmit', 'Search', 'disabled');



Via URL: http://www.w3schools.com/tags/tag_input.asp
I found the default recommand attribute value for
Code:
'disable'
is
Code:
'disabled'
:-)

Thank you so much. My problem solved with your help. I posted my code here.