Re: Setting the "Value" of "Options" in a drop down...
On Tue, Mar 5, 2013 at 6:17 PM, April DeRossett
<april.derossett@gmail.com> wrote:
> Hello!
>
> Here is what I have in my view:
>
> if($biddetail['Biddetail']['Sold'] == 'SOLD'){$otherstate = 'OPEN';} else
> {$otherstate = 'SOLD';}
> echo $this->Form->input('Sold', array('options' =>
> array($otherstate),'empty' => $biddetail['Biddetail']['Sold']));
>
> Is there no way to set the value to equal to the option? ie value = 'SOLD'
> rather than value = '0'. As you can see above the values change based on
> the current value populated in the data base...
>
> I don't want to have to go back and add a table to hold two values that will
> never change. Any solutions? I have already read the documentation at:
> http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html which does
> not provide a solution for this question.
The manual has no solution to your question because you're going about
it the wrong way, I'm afraid. If you'll only ever have 2 states (*)
you may as well make the table column a bit (1/0). You've named it
"Sold" (more on that in a sec) so presumably a 1 would represent
"yes". You could reverse this and name the column "open".
In any case, you could then simply use a checkbox.
I can't offer any more without seeing your table schema, although your
column names should be all lowercase. Normally, your model would be
BidDetail, and the table bid_details, but it's not really so important
as long as you're consistent.
(*) And are you absolutely certain of that? If not, bite the bullet
and go make that other table and use find('list') to get what you
need.
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home