Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] Default values

[SOLVED] Default values 06 Oct 2011 12:58 #131

  • zutiste
  • zutiste's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 1
  • Karma: 3
What is the value to specify for boolean data type ? true/false ? 1/0 ?
Can I specify a default value "today" for the date data type ?
Last Edit: 27 Oct 2011 12:37 by admin.
The administrator has disabled public write access.

Re: default values 06 Oct 2011 16:11 #135

  • griiettner
  • griiettner's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 12
  • Karma: 8
I'm not sure if we can configure that, but my results are "0" as default value. We are facing basically the same issues.

What I did, after the component was generated, I changed the default values manually...
Paulo Griiettner
The administrator has disabled public write access.

Re: default values 06 Oct 2011 16:33 #136

  • Kevin
  • Kevin's Avatar
The default values for the fields are only set after the form is saved.

They do not show up on the new form when it is being filled in.

If you set the default for the bool field to " 1 " (meaning yes) and it isn't set as a required field it will be stored in the database as 1 only if no one clicks it.

This is the same for other default values.
If you have a string or text field for someones name and you give it the default PETER then it won't show on the form but will be entered if the field is ignored.
Last Edit: 06 Oct 2011 16:34 by Kevin. Reason: Typo
The administrator has disabled public write access.

Re: default values 06 Oct 2011 17:19 #139

  • Kevin
  • Kevin's Avatar
zutiste wrote:
Can I specify a default value "today" for the date data type ?

As for the default date value "Today"

Have you tried the wizards "Creation date" and "Modification date" for the tables.

I just gave them a go and they work great.

Just tell it to autogenerate the field for you and leave it at that.

You don't have to include it in your page it's a hidden field that it saved every time the table is saved and the dates are added for you.
The administrator has disabled public write access.

Re: default values 07 Oct 2011 12:12 #158

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I confirm, if you want to preset a form, fill the defaults values in the initData() method of the concerned model... or directly in the view or template. (depends the use)

The defaults values you specify in Cook are placed in the check() method of the table file.
By this way, whatever the method you use to create an item, the default is active.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.094 seconds

Get Started