martinluff Posted January 27, 2011 Posted January 27, 2011 Suppose I want to set a default value for a field - let's say I've a template for 'cars' and I have a text field for colour and 85% of the cars I sell are black; so each time I create a new car page it would make sense to have black as the default value in this field to speed up page creation. Wonder if it would make sense to have a config for some field types to set default value? Or perhaps there's just another easy way to do this?
Adam Kiss Posted January 27, 2011 Posted January 27, 2011 I think there is currently no default value, so until that's added/resolved, I think creating some custom module with page::save() hook is your best bet. You just hook on save [before/after, doesn't matter] and edit 'default' fields with default value if blank.
ryan Posted January 27, 2011 Posted January 27, 2011 Adam is right that there is no default value yet. I agree it should be there, and it's in the Fieldtype module's interface to support it. But it's not implemented in the core. This is a side effect of this being a new project, and some non-crucial details like this are missing (though, this particular one used to be there). The way I usually handle defaults is from the template side. If something has an empty value, then (depending on the field and situation) I will output a default value. The advantage is that there aren't a lot of repeated default values in the DB. But that's too much of a compromise, so default values will be coming. This is one of those things I had in there for awhile, and then took it out to think about it and revisit it later.
martinluff Posted January 27, 2011 Author Posted January 27, 2011 @adamkiss - gives me some ideas and helps me get my head round the system - thanks @ryan, OK makes sense and these are details rather than key issues + of course very early days
BFD Calendar Posted October 14, 2013 Posted October 14, 2013 Apart from a default value it would also be nice to have a field that generates a unique ID with numbers counting like 'name0001', 'name0002', etc.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now