From bd43e5d384bed21ec3ddad40f34167ca20b1566d Mon Sep 17 00:00:00 2001 From: Matheus Garcia Date: Mon, 24 Jun 2019 16:52:10 -0300 Subject: [PATCH] =?UTF-8?q?Trata=20caso=20de=20inexist=C3=AAncia=20de=20ca?= =?UTF-8?q?mpo=20customizado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/util.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/classes/util.php b/classes/util.php index 86e9227..336652e 100644 --- a/classes/util.php +++ b/classes/util.php @@ -81,15 +81,19 @@ function obtemCampoCustomizadoCurso($idCurso, $nomeCampo) { "; $valueArray = $DB->get_record_sql($sql, [$idCurso, $nomeCampo]); - $value = $valueArray->value; - $options = $valueArray->options; - if($options == null) { - return $value; + if($valueArray) { + $value = $valueArray->value; + $options = $valueArray->options; + + if($options == null) { + return $value; + } else { + $optionsArray = preg_split("/\s*\n\s*/", trim($options)); + return $optionsArray[$value-1]; + } } else { - - $optionsArray = preg_split("/\s*\n\s*/", trim($options)); - return $optionsArray[$value-1]; + return ''; } }