/** * Implements getValues. * * @return array */ public function getValues() { if (isset($this->post->values) && isset($this->post->values->form_id)) { $form = $this->form_query->getForm($this->post->values->form_id); $errors = array(); foreach ($form['required_fields'] as $key => $required) { if (!isset($this->post->values->{$key})) { $errors[] = $required; } } if (count($errors) > 0) { foreach ($errors as $error) { Messages::set($error . ' is required.', 'Error'); } return array(); } $controller = Factory::build($form['controller']); $validate = $controller->validate(); if ($validate !== TRUE) { return $validate; } return $controller->submit(); } else { Messages::set('Your form has expired or is invalid.', 'Warn'); } }
/** * Implements getEditor. * * @return array */ public static function getEditor() { $query = Factory::build('/Mongular/Query/ElementQuery'); $blogs = $query->getAllElementsWithController(); foreach ($blogs as $blog) { $options[] = array('name' => $blog['name'], 'value' => $blog['_id']->{'$id'}); } //Subject to change. Not sure what settings I want to make available $fields = array(array('key' => 'parent', 'type' => 'select', 'label' => 'Blog', 'required' => TRUE, 'options' => $options)); return $fields; }