Tuesday, February 2, 2010

Re: Form inputs showing incorrect value

echo $form->input('active', array( 'label' => 'Active Clone',
'options' => array('no' => 'no', 'yes' => 'yes'), 'default' =>
'yes' ));

On Feb 2, 11:04 pm, McScreech <scre...@sympatico.ca> wrote:
> Hello,
>
> I have edit/add views that are not retaining the correct values when
> they exist nor displaying the desired default values when new records
> are created. The following code examples look the same as other select
> type inputs in my code that DO work, I cannot seem to find my error.
> In the following example both fields display a value of 'no'
> regardless of what data the record actually contains.
>
> Any suggestions on where I should look next?
> Does the order the 'options' are listed matter?
> Are either 'active' or 'complete' reserved words?
>
> Thanx, DaveT.
>
> //////////////// The data:
> [Clon] => Array (
>         [id] => 3
>         [name] => 05-0000295
>         [active] => yes
>         [complete] => no
> )
>
> //////////////// The clons\edit.ctp snippet:
> <?php
>         echo $form->input('active', array( 'label' => 'Active Clone',
>                 'options' => array('no','yes'), 'default' => 'yes' ));
>         echo $form->input('complete', array( 'label' => 'Record Complete',
>                 'options' => array('no','yes'), 'default' => 'no' ));
> ?>
>
> //////////////// The HTML output:
> <div class="input select">
>         <label for="ClonActive">Active Clone</label>
>         <select name="data[Clon][active]" id="ClonActive">
>                 <option value="0" selected="selected">no</option>
>                 <option value="1">yes</option>
>         </select>
> </div>
> <div class="input select">
>         <label for="ClonComplete">Record Complete</label>
>         <select name="data[Clon][complete]" id="ClonComplete">
>                 <option value="0" selected="selected">no</option>
>                 <option value="1">yes</option>
>         </select>
> </div>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: