views:

28

answers:

1

Hi all,

I am using cakePHP 1.26. I am sorry to ask this question, but I couldn't work out how to 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?

+1  A: 

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.

Travis Leleu