开发者

How to use the cakePHP built-in FORM helper to generate Text and Hidden text boxes

开发者 https://www.devze.com 2023-01-07 09:03 出处:网络
I am using cakePHP 1.26.I am sorry to ask this question, but I couldn\'t work out how to开发者_StackOverflow中文版 use the cakePHP built-in FORM helper to generate the code like these two:

I am using cakePHP 1.26. I am sorry to ask this question, but I couldn't work out how to开发者_StackOverflow中文版 use the cakePHP built-in FORM helper to generate the code like these two:

<input type="text" name="data[Test][quote]" id="data[Test][quote]" size="12" style="font-family:Arial" value="helloworld" readonly>

<input type="hidden" name="data[Test][quote]" id="data[Test][quote]" value="helloworld">

Could you help me please?


Try this:

<?php
 echo $form->input( 'Test.quote', array( 'type' => 'hidden', 'value' => 'helloworld' ) );
 echo $form->input( 'Test.quote', array( 'type' => text', 'size' => 12, 'style' => 'font-family:Arial', 'value' => 'helloworld', 'readonly' => 'readonly' ) );
?>

If you're putting them both on the same page, with the same name, make sure to put the hidden input before the text. That way the text input will override the hidden input if someone enters something in the field.

0

精彩评论

暂无评论...
验证码 换一张
取 消