Permalink
Browse files

Merge pull request #1266 from CraigChilds94/bugfix/custom-site-edit-e…

…rror-#1259

Custom site variable saving fix. Issue #1259
  • Loading branch information...
CraigChilds94 committed Mar 7, 2018
2 parents af7bd00 + 7064244 commit 08e8e507909ee55b588674563b8ea21646ed9425
Showing with 21 additions and 23 deletions.
  1. +11 −13 anchor/routes/variables.php
  2. +10 −10 composer.lock
@@ -100,33 +100,31 @@
});
Route::post('admin/extend/variables/edit/(:any)', function ($key) {
$input = Input::get(['key', 'value']);
$input['key'] = 'custom_' . slug($input['key'], '_');
$input = Input::get(['key', 'value']);
foreach ($input as $key => &$value) {
$value = eq($value);
}
$original = slug($input['key'], '_');
$validator = new Validator($input);
$validator->add('valid_key', function ($str) use ($key) {
$validator->add('valid_key', function ($str) use ($original) {
// no change
if ($str == $key) {
return false;
// Don't check against the same key
if ($str == $original) {
return true;
}
// check the new key $str is available
return Query::table(Base::table('meta'))
->where('key', '=', $str)
->count() != 0;
->count() == 0;
});
// include prefix length 'custom_'
$validator->check('key')
->is_max(8, __('extend.name_missing'))
->is_max(1, __('extend.name_missing'))
->is_valid_key(__('extend.name_exists'));
$key = $input['key'] = 'custom_' . $original;
$value = $input['value'];
if ($errors = $validator->errors()) {
Input::flash();
Notify::error($errors);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 08e8e50

Please sign in to comment.