使用 10 月 cms 的构建版本 422 和 Rainlab 博客插件,不可能拥有非英语音节的博客文章别名,每次都会显示 "别名格式无效"。
是否有解决方案或方法来解决这个限制?
使用 10 月 cms 的构建版本 422 和 Rainlab 博客插件,不可能拥有非英语音节的博客文章别名,每次都会显示 "别名格式无效"。
是否有解决方案或方法来解决这个限制?
public $rules = [
'title' => 'required',
// 'slug' => ['required', 'regex:/^[a-z0-9\/\:_\-\*\[\]\+\?\|]*$/i', 'unique:rainlab_blog_posts'],
'content' => 'required',
'excerpt' => ''
];
use Rainlab\Blog\Models\Post;
class Plugin extends PluginBase
{
public function boot()
{
// Extend post Model
Post::extend(function($model) {
// Only do stuff when validation is triggered
$model->bindEvent('model.beforeValidate', function() use ($model) {
// Find the regex holding value to avoid hardcoding array index
foreach($model->rules as $key => $value) {
if(strpos($value, 'regex:') !== false) {
// unset validation rule containing the regex.
unset($model->rules[$key]);
break;
}
}
}
});
}
}