I have a way of doing it, while I am not sure how good it is in
CakePHP terms, but it should work.

Set a variable (Suppose $test) for default value i.e. 'Beavis' in your
controller. But this should be set only in case when no data is posted
which means the page loads for the first time.

In your view file check:
if($test)
//Show your above written code with the test variable
$form->input('User.name', array('type'=>'text', 'value'=>$test));
else
//Show input type with no value, which should pick user entered value
the Cake way when the form is posted
$form->input('User.name', array('type'=>'text'));

Hope this works for you :)

On Jan 23, 10:12 am, Matt Huggins <[EMAIL PROTECTED]> wrote:
> I'm currently using CakePHP 1.2 beta.  I already know that you can do
> something like the following in order to provide a default INPUT
> value:
>
> $form->input('User.name', array('type'=>'text', 'value'=>'Beavis'));
>
> The problem is that I only want this default value to display when the
> page is first being loaded (i.e.: during a GET that is not the result
> of a form submission).  Currently, when the user submits the form
> submits, I want the page to display the second time with whatever
> value the user entered (i.e.: Controller::$data['User']['name']).
> Currently, the value "Beavis" is always put into the textbox, even
> after the form is submitted with a different value.
>
> How can I display a default value when a form IS NOT submitted, and
> the user's value when a form IS submitted.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to