3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2318 Views |
-
No UpperCase?

27 March 2009 at 6:22am
Creating a custom page type, and working on the custom template portion.
Have a need to convert the contents of a TextField to upper case.
Notice that $FieldName.LowerCase works just fine - but apparently $FieldName.UpperCase was left out?
Any ideas on how I can accomplish this?
Thanks!
-
Re: No UpperCase?

27 March 2009 at 9:12am
If you don't mind doing this in CSS, you can use the text-transform directive.
This may not be what you're looking for....
-
Re: No UpperCase?

28 March 2009 at 1:47am
Appreciate the response Ben - but not quite what I was looking for.
Pretty astounded that they took the time to put in a LowerCase method, but decided to not take the extra step and supply a corresponding UpperCase method.
* scratches head *
-
Re: No UpperCase?

28 March 2009 at 2:45am Last edited: 28 March 2009 2:45am
Well, regardless of why it wasn't added in - I decided to take some initiative and add the following code snippet to the file:
{SilverStripeDirectory}\sapphire\core\model\fieldtypes\DBField.phpfunction UpperCase() {
return Convert::raw2xml(strtoupper($this->value));
}I put this right underneath the LowerCase function.
Solved the problem...
-
Re: No UpperCase?

31 March 2009 at 11:13am
Has anyone figured out to add this kind of functionality to the DBField class and subclasses without hacking the core? I tried Object::useCustomClass() but apparently you can only use that for certain core classes. I've been wanting to add a toCamelCase and toSnakeCase method to Varchar and similar classes, but I haven't found out how to do it without hacking core files.
-
Re: No UpperCase?

1 April 2009 at 4:53am
webbower - as I felt it bad form to update the core in order to add this functionality, I asked on the General Questions forum on the best way to get this functionality into the core for a future release.
http://silverstripe.org/general-questions/show/257202#post257202
As the method I'm proposing is ridiculously simple (just a copy of the toLowerCase except for UpperCase), I figure I'll just submit a simple patch request.
Hope that helps...
-
Re: No UpperCase?

1 April 2009 at 5:10pm
ImacSS - functions in the core esp round strings, date etc are just added when we need them in a project. I doubt there is a 'design' decision behind not including it so I'm sure if you submit a patch it will be included in the next release
As for your post "How to make a recommendation?" I didnt see it in that forum but anyway as a note you should usually make a ticket on open.silverstripe.com with the patch / changes you wish. If its a large change or an API change then post it to the ss-dev mailing list as this will generate some discussion
-
Re: No UpperCase?

2 April 2009 at 2:57am
willr - thank you very much for the info. I have posted a patch request using the info you provided.
thanks again...
| 2318 Views | ||
|
Page:
1
|
Go to Top |


