Skip to content

Commit

Permalink
Validation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewilkins committed Oct 16, 2017
1 parent fd29b80 commit 3e1ffd6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion system/user/addons/vmg_chosen_member/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

if ( ! defined('VMG_CM_VERSION'))
{
define('VMG_CM_VERSION', '3.0.3');
define('VMG_CM_VERSION', '3.1');
}

/**
Expand Down
28 changes: 28 additions & 0 deletions system/user/addons/vmg_chosen_member/ft.vmg_chosen_member.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,34 @@ public function save_var_settings($data)
return $this->save_settings($data);
}

/**
* Validate the submitted data
*/
public function validate($data)
{
if (isset($this->settings['field_required']) && $this->settings['field_required'] === 'y') {
if (empty($data) || $data === ['__empty__']) {
return ['error' => 'The '.$this->settings['field_label'].' field is required.', ];
}
}

return true;
}

/**
* Validate Cell
*/
function validate_cell($data)
{
// is this a required column?
if ($this->settings['col_required'] == 'y' && $this->validate($data) !== true)
{
return lang('col_required');
}

return TRUE;
}

/**
* Save Field
*/
Expand Down

0 comments on commit 3e1ffd6

Please sign in to comment.