function action_index() {
$messages = null;
$socialNetworks = Model_Ntk_Social_Network::getAll();
if (\Input::method() == "POST") {
if ( \Security::check_token()) {
try
{
$user = Model_Ntk_User::forge($_POST);
if(!empty($_POST['socialnetworks'])) {
foreach ($_POST['socialnetworks'] as $socialId => $social) {
$socialNetwork = new Model_Ntk_Users_Social_Network();
$socialNetwork->users_id = $user->id;
$socialNetwork->social_networks_id = $socialId;
$socialNetwork->description = $social;
$user->socials[] = $socialNetwork;
}
}
if ($user->save(null,true)) {
\Response::redirect('/');
}
}
catch (Orm\ValidationFailed $e)
{
$errors = array();
//$messages = $e->getMessage();
foreach ($e->fieldset()... as $error)
{
$errors[] = array(
//'field' => $error->field, // the field that caused the error
'value' => $error->value, // the value that is in error
'message' => trim($error->get_message(false, '\t', '\t')), // the error message
'rule' => $error->rule, // the rule that failed
'params' => $error->params // any parameters passed to the rule
);
}
// return $errors;
print_r($errors);
die;
$messages = implode(",", $errors);
}
} else {
$messages = "Token failed, try again please";
}
}
$data = array(
'socialnetworks' => $socialNetworks,
'gitrepos' => $gitRepos,
'skillcategories' => $skillcategories,
'languages' => $languages,
'messages' => $messages
);
return Response::forge(View::forge('site/index', $data, false));
}
It looks like you're new here. If you want to get involved, click one of these buttons!