5121 Posts in 1527 Topics by 1119 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1504 Views |
-
ModelAdmin: Length limitation on Varchar

10 May 2010 at 3:27am
In my model I've defined: 'Title' => 'Varchar(32)',
In the ModelAdmin I can enter any number of characters and successfully save the object - if I've entered more than 32 characters in the title they are also displayed after saving.
If I reload the object, the title it is cut off after 32 characters (as the database simply doesn't store more than this). I would have expected / hoped for some kind of warning when trying to save more than the possible characters - currently they are lost without any kind of message.Is this a bug, am I doing something wrong or how can this be fixed?
-
Re: ModelAdmin: Length limitation on Varchar

10 May 2010 at 10:44pm
I'm not sure ModelAdmin (or any of the CMS form fields) provide this sort of automatic validation for lengths of data. You can set the max length of the TextField (eg 32) in the constructor but don't think a nice error message will be generated (just won't allow any more characters) the form valldation is one of the areas on the todo list.
-
Re: ModelAdmin: Length limitation on Varchar

10 May 2010 at 11:37pm
Thanks for pointing that out. The following did the trick:
function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new TextField('Title', 'Title', '', 32), 'Subtitle');
$fields->addFieldToTab('Root.Main', new TextField('Subtitle', 'Subtitle', '', 64), 'Text');
return $fields;
}Would be cool if SilverStripe could do that automagically as the current cutting of is definitely not nice.
I guess there is no point in filing a ticket as this is already on the roadmap?
| 1504 Views | ||
|
Page:
1
|
Go to Top |


