Tuesday, April 30, 2013

Re: Carregar campo tipo tinyint(1)

Hi Anderson,

I don't speak Portuguese but Google Translator made it :P

you will see that a tinyint(1) is likely a flag, on/off.

And you are using an 'options' key in the options array.
$this->Form->input(String $fieldName, Array $options); // Parameters are the fieldName and the $options array. 

Now, if what you want is to set the initial state of the checkbox, use the 'checked' key inside the $options array.
$this->Form->input('status', array(
'checked' => false                                                            // This can be true or false, depending if you want it active or inactive respectively.
));


Regards,
Ciul

Translation:
Guys, good afternoon.

I did a CRUD client, where one of the fields of my table is of type "tinyint (1)", the field name is "status".

So when I click on the edit controller that catches my view it loads the form fields correctly, including the field of type "select" state, but the make up "status" does not load properly, I will explain what happens.

I have the following input:

$ this-> Form-> input ('status', array (
             'options' => array (true => 'Active', false => 'Inactive') // ERROR: Don't set an 'options' key inside the $options array
         ))

Is recorded in Table 1 for true and 0 for false, but when the client is as inactive (0) and I click change, it should load the status field as "Inactive", but it loads as "Active", do not know if because it is the first in the options.

Can anyone help me with this??

thank you,

Anderson

--
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.
 
 

No comments: