Monday, May 19, 2014

Re: 3.0 - Saving data using Form with HasOne relationship

Thanks a lot, i changed from username to user_id and its working perfectly

but the second one is not working

here is my table structure

CREATE TABLE IF NOT EXISTS `profiles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(40) NOT NULL,
  `address` varchar(70) NOT NULL,
  `email` varchar(30) NOT NULL,
  `mobile` varchar(20) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created` datetime DEFAULT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;

Below error is showing:

Error: Call to a member function format() on a non-object
File /var/www/html/test3/App/Template/Profiles/index.ctp
Line: 22 ( <td><?= h($profile->created->format(DATE_RFC850)) ?></td> )

After removing Format(Date_RFC850)), the data is saving but created field is entered as NULL.

Thanks again
Bayezid


On Mon, May 19, 2014 at 10:03 AM, Dakota <waltherlalk@gmail.com> wrote:
The line echo $this->Form->input('username', ['options' => $pUser]); should be 'user_id'. Also, if the variable is 'users' cakephp will automatically pick it up as the options for the field.

Check that your created field allows null with default null.

--
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.
For more options, visit https://groups.google.com/d/optout.

--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: