function render() { if ($this->loginQueued) { FlashBag::add('success', "Login Success"); $this->doLogin(); return array('type' => 'redirect', 'url' => $this->route->root()); } return array('type' => 'template', 'template' => 'pages/login.twig', 'data' => ['staticRoot' => $this->app->getStaticRoot(), 'title' => $this->app->getAppName(), 'welcomeMessage' => $this->welcomeMessage, 'endpoint' => $this->route->root(), 'valueBag' => json_encode(ValueBag::getValues()), 'bodyclass' => 'login-page', 'error' => $this->error, 'username' => $this->url->get('username', '')]); }
public function handle_set_form_values() { $form = new FormHelper(array(), $this->dataProvider->getEditFormConfig()); $url = new UrlHelper(); // let's not worry about validation right now. $values = json_decode($url->get("values_json", "{}"), true); if ($form->validate($values)) { $this->dataProvider->setRow($url->get("item_id", null), $values); FlashBag::add("alert", "Item has been updated", "success"); return array('type' => 'json', 'data' => array('success' => true)); } else { // TODO show errors on validation fail throw new \Exception("Cannot validate values"); } }
public static function logObject($object) { FlashBag::add("log", json_encode($object), "json"); }
public function handle_set_form_values() { $form = new FormHelper(array(), $this->dataProvider->getEditFormConfig()); $url = new UrlHelper(); $values = json_decode($url->get("values_json", "{}"), true); if (empty($values)) { return array('type' => 'json', 'data' => array('success' => true)); } //validate $failedValues = $this->dataProvider->validateRow($values); if (empty($failedValues)) { $this->dataProvider->setRow($url->get("item_id", null), $values); FlashBag::add("alert", "Item has been updated", "success"); return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => true)); } else { FlashBag::add("alert", "Could not update certain fields", "error"); return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => false, 'failedValues' => $failedValues)); //throw new \Exception("Cannot validate values"); } }
public function handle_set_form_values() { if ($this->app->isReadOnly()) { throw new Exception("Read Only"); } $form = new FormHelper(array(), $this->dataProvider->getEditFormConfig()); $url = new UrlHelper(); $values = json_decode($url->get("values_json", "{}"), true); if (empty($values)) { return array('type' => 'json', 'data' => array('success' => true)); } //validate $failedValues = $this->dataProvider->validateRow($values); if (empty($failedValues)) { $url = new UrlHelper(); $rowId = $url->get("item_id", null); $summaryKey = $this->dataProvider->getSummaryColumns()[0]['key']; $rowData = $this->dataProvider->getRow($rowId); $rowName = $rowData[$summaryKey]; $this->dataProvider->setRow($url->get("item_id", null), $values); FlashBag::add("alert", "Item {$rowName} has been updated", "success"); return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => true)); } else { FlashBag::add("alert", "Could not update certain fields", "error"); return array('type' => 'json', 'data' => array('success' => true, 'dataValid' => false, 'failedValues' => $failedValues)); //throw new \Exception("Cannot validate values"); } }