7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » CheckboxField default on - checked
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 2080 Views |
-
CheckboxField default on - checked

5 January 2010 at 11:05am
How do I set my checkbox to default to the checked position?
$fields->addFieldToTab("Root.Content.Main", new CheckboxField('ShowHeadNav','Header Navigation: Check the checkbox ...'));
-
Re: CheckboxField default on - checked

5 January 2010 at 2:17pm
... new CheckboxField('ShowHeadNav','Header Navigation: ', 1));
I found this - adding the ,1 to the code. However, now that the tables are made, I cannot get it right. I have gone to the database to find the tables for this but do not see anything.
Ran dev/build/?flush=1 - still nothing is changing. The fields are gone in the editor, but when I update the code from Page.php it just adds the fields back in the way I left them.
Any ideas how to reset this, or remove the tables?
-
Re: CheckboxField default on - checked

5 January 2010 at 2:32pm
Found the field in the table for table "Page" and change the default to 1.
Now new pages default to one - checked.
-
Re: CheckboxField default on - checked

5 January 2010 at 2:52pm
Is this just for new records having a default value? Just use the $defaults array.
static $defaults = array (
'MyBoolean' => '1'
); -
Re: CheckboxField default on - checked

5 January 2010 at 3:23pm
Hi UncleCheese,
Do i place this in the Page.php file?
And where if so?
Thank you
-
Re: CheckboxField default on - checked

5 January 2010 at 3:27pm Last edited: 5 January 2010 3:34pm
I got it, thank you
-
Re: CheckboxField default on - checked

5 January 2010 at 3:42pm
Place it in whatever class contains the field for which you want a default value. If it is one of the core Page fields, e.g. "ShowInMenus", then put it there, but if it's a custom field you've added on a Page subclass, it belongs in that class.
-
Re: CheckboxField default on - checked

5 January 2010 at 6:05pm
Thank you, I added it under
class Page extends SiteTree {
Can you help me with this question, related to extend what I am doing here in the footer...
http://www.silverstripe.org/customising-the-cms/show/276269#post276269
| 2080 Views | ||
|
Page:
1
|
Go to Top |

