You probably have to not only state that you use the State model, but
also the Person model.
Or it may be enough if you in the view, creates the state field using
'State.state', so that the forms helper, know to which model the state
belong.
Hope this helps you on the way,
   John

On Feb 17, 6:28 am, aveev <nashrullah_a...@yahoo.com> wrote:
> Hi, I'm a new cake user...
> I have this table ddl
> CREATE TABLE IF NOT EXISTS `people` (
>   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
>   `name` varchar(30) NOT NULL,
>   `pob` varchar(25) DEFAULT NULL,
>   `dob` date NOT NULL,
>   `address` text NOT NULL,
>   `created` datetime DEFAULT NULL,
>   `modified` datetime DEFAULT NULL,
>   PRIMARY KEY (`id`)
> )
> when I try to create a view using a form helper, I hope that the form will
> be populated automatically according to field type (text field type for name
> and pob, datetime for dob, etc). Here's my view add.ctp:
>
>     <h1>Add Person</h1>
> <?
>         echo $form->create('Person');
>         echo $form->input('name');
>         echo $form->input('pob');
>         //echo $form->select('state', array($states));
>         echo $form->input('dob');
>         echo $form->input('address');
>
>         echo $form->end('Save');
>
> ?>
>
> and here's my people_controller
> class PeopleController extends AppController {
>                 var $name = 'Persons';
>                 //var $uses = array('State');
>
>         function add() {
>                 /*$states = $this->State->find('list', array ('fields' => 
> array ('name',
> 'name')));
>                 $this->set('states',$states);*/
>                 debug($this->data);
>         }
>
> The form displays correctly (form fields are displayed according to the
> field type in db table). But as I use another model (State) in the
> controller above by uncommenting this line of code:
> var $uses = array('State');
> in the controller, the dob form field is wrongly displayed as text, not
> datetime field type..
>
> Can I say that the ability of form helper to autopopulate the form fields
> correctly only happen when we use default model ? Because when I include
> another model in the form, it breaks ..
> Thanks for any comment..
> --
> View this message in 
> context:http://old.nabble.com/Form-helper-doesn%27t-show-correct-field-type-w...
> Sent from the CakePHP mailing list archive at Nabble.com.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to