/** * @action csv upload page * @view examresult/upload */ public function action_upload() { $view = View::factory('examresult/upload')->bind('form', $form)->bind('success', $success)->bind('warning', $warning); $errors = array(); if ($this->request->method() === 'POST' && $this->request->post()) { $examgroup_id = $this->request->post('examgroup_id'); $exams = Model_Examgroup::get_exams($examgroup_id); $students = Model_Examgroup::get_students($examgroup_id); $csv = new Examresult_Csv($_FILES['csv_file'], $exams, $students); if ($csv->validate()) { $datasets = $csv->datasets(); Model_Examresult::save_results($datasets); $success = 'Results uploaded successfully. Click <a href="%s">here</a> to view them'; $success = sprintf($success, Url::site('examresult/edit/examgroup_id/' . $examgroup_id)); } else { $errors = array('csv_file' => $csv->errors('invalid_extension')); $warning = $csv->errors('warning'); } } $form = new Stickyform('examresult/upload', array('enctype' => 'multipart/form-data'), $errors); $form->default_data = array('examgroup_id' => '', 'csv_file' => ''); $form->posted_data = $this->request->post(); $examgroups = ORM::factory('examgroup')->find_all()->as_array('id', 'name'); $form->append('Select Exam Group:', 'examgroup_id', 'select', array('options' => $examgroups, 'attributes' => array('id' => 'examgroup_id')))->append('CSV File:', 'csv_file', 'file')->append('Upload', 'upload', 'submit', array('attributes' => array('class' => 'button')))->process(); $this->content = $view; Breadcrumbs::add(array('Exams', Url::site('exam'))); Breadcrumbs::add(array('Manage Results', Url::site('examresult/upload'))); }
protected function form($saved_data, $submitted = false) { $action = 'system'; // get all roles $roles = ORM::factory('role')->find_all()->as_array('id', 'name'); // get all institution types $institution_types = ORM::factory('institutiontype')->find_all()->as_array('id', 'name'); // get languages $language = array('1' => 'English'); $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $fields = array('name', 'institutiontype_id', 'logo', 'website', 'address', 'config_language_id', 'config_membership', 'config_default_role', 'config_user_approval'); $form->default_data = array_fill_keys($fields, ''); if ($saved_data) { $saved_config = $saved_data['config']; unset($saved_data['config']); foreach ($saved_config as $key => $value) { $saved_data['config_' . $key] = $value; } $form->saved_data = $saved_data; } //$form->saved_data = $saved_data; if ($this->request->method() === 'POST' && $this->request->post()) { $form->posted_data = $this->request->post(); } else { $form->posted_data = array(); } $form->append('Institution Name', 'name', 'text')->append('Institution Type', 'institutiontype_id', 'select', array('options' => $institution_types))->append('Logo', 'logo', 'hidden')->append('Website', 'website', 'text')->append('Address', 'address', 'textarea')->append('Language', 'config_language_id', 'select', array('options' => $language, 'attributes' => array('name' => 'config[language_id]')))->append('Membership', 'config_membership', 'checkbox', array('attributes' => array('name' => 'config[membership]', 'value' => 1)))->append('Default Role', 'config_default_role', 'select', array('attributes' => array('name' => 'config[default_role]'), 'options' => $roles))->append('User Approval', 'config_user_approval', 'checkbox', array('attributes' => array('value' => 1, 'name' => 'config[user_approval]')))->append('Save Changes', 'save', 'submit', array('attributes' => array('class' => 'button')))->process(); // var_dump($form); return $form; }
protected function form($saved_data, $submitted = false) { $form = new Stickyform('notice/settings', array(), $this->_errors); $fields = array('status', 'sender_email'); $form->default_data = array_fill_keys($fields, ''); $form->saved_data = $saved_data; if ($this->request->method() === 'POST' && $this->request->post()) { $form->posted_data = $this->request->post(); } else { $form->posted_data = array(); } $form->append('Send Notices', 'status', 'select', array('options' => array(0 => 'disabled', 1 => 'enabled'))); $form->append('Email Sender Address', 'sender_email', 'text')->append('Save Changes', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); return $form; }
private function form($action, $submitted = false, $saved_data = array()) { $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('name' => '', 'description' => ''); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Name', 'name', 'text'); $form->append('Description', 'description', 'textarea', array('attributes' => array('cols' => 50, 'rows' => 5))); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); $id = $this->request->param('id'); $links = array('cancel' => Html::anchor('/batch/', 'or cancel'), 'upload' => Html::anchor('user/uploadcsv/batch_id/' . $id, 'Upload Now', array('class' => 'button'))); $action = $this->request->action(); $view = View::factory('batch/form')->bind('links', $links)->bind('form', $form)->bind('action', $action)->bind('id', $id); $this->content = $view; }
public function action_edit() { if ($this->request->method() === 'POST' && $this->request->post()) { $event = ORM::factory('event', $this->request->post('event_id')); $validator = $event->validator($this->request->post()); $lecture = ORM::factory('lecture', $this->request->post('lecture_id')); if ($validator->check()) { $from = strtotime($this->request->post('date')) + $this->request->post('from') * 60; $to = strtotime($this->request->post('date')) + $this->request->post('to') * 60; $event->room_id = $this->request->post('room_id'); $event->eventstart = $from; $event->eventend = $to; $event->cancel = (int) $this->request->post('cancel'); $event->save(); $lecture->start_date = $from; $lecture->end_date = $to; $lecture->save(); if ($this->request->post('cancel')) { $feed = new Feed_Lecture(); $feed->set_action('canceled'); $feed->set_course_id($event->course_id); $feed->set_respective_id($event->id); $feed->set_actor_id(Auth::instance()->get_user()->id); $feed->save(); $feed->subscribe_users(); } $json = array('success' => 1, 'message' => array('Event is edited successfully')); } else { $json = array('success' => 0, 'errors' => array_values($validator->errors('exam'))); } echo json_encode($json); exit; } $id = $this->request->param('id'); $lecture_id = $this->request->param('lectId'); $event = ORM::factory('event', $id); $form = new Stickyform('', array(), array()); $form->default_data = array('date' => '', 'room_id' => '', 'from' => '', 'to' => '', 'cancel' => '1'); $conflict_event = $event->get_conflict_event(); $event_details = array(); if ($conflict_event) { $class = 'Event_' . $conflict_event->eventtype; $dynamic_object = new $class($conflict_event->id); $event_details = $dynamic_object->get_event_details(); } $form->saved_data = array('date' => date('Y-m-d', $event->eventstart), 'cancel' => $event->cancel); $form->append('Date', 'date', 'text', array('attributes' => array('class' => 'date'))); $form->append('Room', 'room_id', 'select', array('options' => array())); $form->append('From', 'from', 'hidden', array('attributes' => array('id' => 'slider-range_from'))); $form->append('To', 'to', 'hidden', array('attributes' => array('id' => 'slider-range_to'))); $form->append('Cancel', 'cancel', 'checkbox', array('attributes' => array('value' => 1))); $form->process(); $slider = array('start' => ($event->eventstart - strtotime(date('Y-m-d', $event->eventstart))) / 60, 'end' => ($event->eventend - strtotime(date('Y-m-d', $event->eventend))) / 60); $view = View::factory('event/edit')->bind('event', $event)->bind('form', $form)->bind('slider', $slider)->bind('conflict_event', $conflict_event)->bind('event_details', $event_details)->bind('lecture_id', $lecture_id); echo json_encode(array('success' => 1, 'html' => $view->render())); exit; }
public function action_index() { $user = Auth::instance()->get_user(); $submitted = FALSE; if ($this->request->method() === 'POST' && $this->request->post()) { if (Arr::get($this->request->post(), 'save') !== null) { $submitted = true; $validator = $user->validator_profile($this->request->post()); $validator->bind(':user', $user); if ($validator->check()) { $user->firstname = $this->request->post('firstname'); $user->lastname = $this->request->post('lastname'); $user->email = $this->request->post('email'); $user->about_me = $this->request->post('about_me'); if ($this->request->post('password')) { $user->password = Auth::instance()->hash($this->request->post('password')); } $user->save(); Session::instance()->set('success', 'Saved successfully.'); Request::current()->redirect('account'); } else { $this->_errors = $validator->errors('register'); } } } $form = new Stickyform('account/index', array(), $submitted ? $this->_errors : array()); $form->default_data = array('firstname' => '', 'lastname' => '', 'email' => '', 'about_me' => ''); $form->saved_data = array('firstname' => $user->firstname, 'lastname' => $user->lastname, 'email' => $user->email, 'about_me' => $user->about_me); $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('First Name', 'firstname', 'text'); $form->append('Last Name', 'lastname', 'text'); $form->append('Email', 'email', 'text'); $form->append('Password', 'password', 'password'); $form->append('About me', 'about_me', 'textarea'); $form->append('Confirm Password', 'confirm_password', 'password'); $form->append('Save Changes', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); $upload_url = URL::site('account/uploadavatar'); $remove_url = URL::site('account/removeimage'); $image = CacheImage::instance(); $avatar = $image->resize($user->avatar, 100, 100); $view = View::factory('account/profile')->bind('form', $form)->bind('upload_url', $upload_url)->bind('remove_url', $remove_url)->bind('user', $user)->bind('success', $success)->bind('avatar', $avatar); Breadcrumbs::add(array('Profile', Url::site('account'))); $success = Session::instance()->get('success'); Session::instance()->delete('success'); $this->content = $view; }
private function form($action, $submitted = false, $saved_data = array()) { $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('name' => ''); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Name', 'name', 'text'); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); return $form; }
private function form($action, $submitted = false, $saved_data = array(), $image = '') { $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('title' => '', 'description' => '', 'url' => '', 'image' => ''); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Title', 'title', 'textarea', array('attributes' => array('class' => 'link_text_area'))); $form->append('Description', 'description', 'textarea', array('attributes' => array('class' => 'link_text_area'))); $form->append('Url', 'url', 'text', array('attributes' => array('class' => 'link_text'))); $form->append('', 'image', 'hidden'); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); $id = $this->request->param('id'); $links_old = array('cancel' => Html::anchor('/link/', 'or cancel')); $action = $this->request->action(); $upload_url = URL::site('link/uploadlinkimg'); $view = View::factory('link/form')->bind('links', $links)->bind('form', $form)->bind('action', $action)->bind('id', $id)->bind('image', $image)->bind('upload_url', $upload_url); $this->content = $view; }
private function form($action, $submitted = false, $saved_data = array()) { $locations = array(); foreach (ORM::factory('location')->find_all() as $location) { $locations[$location->id] = $location->name; } $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('room_name' => '', 'room_number' => '', 'location_id' => ''); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Name', 'room_name', 'text'); $form->append('Number', 'room_number', 'text'); $form->append('Location', 'location_id', 'select', array('options' => $locations)); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); return $form; }
public function action_uploadcsv() { if ($this->request->method() === 'POST' && $this->request->post()) { if (Arr::get($this->request->post(), 'save') !== null) { $filename = $_FILES['csv']['name']; $extension = explode(".", $filename); if (isset($extension[1]) && strtolower($extension[1]) === "csv") { //Validation of file $filename = $_FILES['csv']['tmp_name']; $handle = fopen($filename, "r"); while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) { $filedata[] = $data; } unset($filedata[0]); $records_added = 0; $error = 0; $user_id = array(); foreach ($filedata as $key => $row) { $data = array('firstname' => isset($row[0]) ? $row[0] : '', 'lastname' => isset($row[1]) ? $row[1] : '', 'email' => isset($row[2]) ? $row[2] : ''); $user = ORM::factory('user'); $validator = $user->validator_create($data); $validator->bind(':user', NULL); if ($validator->check()) { //add user $user->firstname = $data['firstname']; $user->lastname = $data['lastname']; $user->email = $data['email']; $password = rand(10000, 65000); $user->password = Auth::instance()->hash($password); $role = ORM::factory('role', $this->request->post('role_id')); $user->save(); $user->add('roles', $role); $user_id[] = $user->id; // assign to batch only if the role of the user is student if ($user->is_role('student')) { if ($this->request->post('batch_id')) { foreach ($this->request->post('batch_id') as $batch_id) { $batch = ORM::factory('batch', $batch_id); $user->add('batches', $batch); } } } // send email self::notify_by_email($user, $password); $records_added += 1; } else { $this->error['warning'] = "There was an error on line # " . $key . " Records Added " . $records_added; $this->error['description'] = implode('<br/>', $validator->errors('register')); $error = 1; break; } } if (!$error) { $this->success = "Users uploaded successfully. Records Added " . $records_added; if ($this->request->post('batch_id')) { foreach ($this->request->post('batch_id') as $batch_id) { $feed = new Feed_Batch(); $feed->set_action('student_add'); $feed->set_course_id('0'); $feed->set_respective_id($batch_id); $feed->set_actor_id(Auth::instance()->get_user()->id); $feed->streams(array('user_id' => $user->id)); $feed->save(); } } } fclose($handle); } else { $this->error['warning'] = "The file you uploaded is not a valid csv file"; $this->error['description'] = ""; } } } $roles = array(); foreach (ORM::factory('role')->find_all() as $role) { $roles[$role->id] = $role->name; } $batches = array(); foreach (ORM::factory('batch')->find_all() as $batch) { $batches[$batch->id] = $batch->name; } $form = new Stickyform('user/uploadcsv', array('enctype' => 'multipart/form-data'), array()); $form->default_data = array('role_id' => '', 'batch_id' => $this->request->param('batch_id', array())); $form->saved_data = array(); $form->posted_data = array(); $form->append('Role', 'role_id', 'select', array('options' => $roles)); $form->append('Select batch', 'batch_id', 'select', array('options' => $batches, 'attributes' => array('multiple' => 'multiple', 'name' => 'batch_id[]'))); $form->append('Upload', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); $links = array('sample' => Html::anchor('/users_sample.csv', 'or click here to download a sample CSV file')); $view = View::factory('user/uploadcsv')->bind('form', $form)->bind('error', $this->error)->bind('success', $this->success)->bind('links', $links); Breadcrumbs::add(array('User', Url::site('user'))); Breadcrumbs::add(array('Upload csv', Url::site('user/uploadcsv'))); $this->content = $view; }
public function action_upload() { $submitted = FALSE; if ($this->request->method() === 'POST' && $this->request->post()) { if (Arr::get($this->request->post(), 'save') !== null) { $submitted = TRUE; $document = ORM::factory('document'); $validator = $document->validator(array_merge($this->request->post(), $_FILES)); $validator->bind(':files', $_FILES['name']); if ($validator->check()) { $filename = Upload::save($_FILES['name'], NULL, UPLOAD_PATH); $document = ORM::factory('document'); $document->values($this->request->post()); $document->name = basename($filename); $document->time = time(); $document->save(); $document->add('courses', $this->request->post('course_id')); $document->add('roles', $this->request->post('role')); foreach ($this->request->post('course_id') as $course_id) { $feed = new Feed_Document(); $feed->set_action('add'); $feed->set_course_id($course_id); $feed->set_respective_id($document->id); $feed->set_actor_id(Auth::instance()->get_user()->id); $stream_data = array('course_id' => $course_id, 'role_id' => $this->request->post('role')); $feed->streams($stream_data); $feed->save(); } Request::current()->redirect('document'); } else { $this->_errors = $validator->errors('document'); } } } $courses = Model_Course::courses()->as_array('id', 'name'); $course_id = Session::instance()->get('course_id'); //remove the current course from the list unset($courses[$course_id]); $form = new Stickyform('document/upload', array('enctype' => "multipart/form-data"), $submitted ? $this->_errors : array()); $form->default_data = array('title' => '', 'user_id' => Auth::instance()->get_user()->id, 'course_id' => 0, 'role' => 0); $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Title', 'title', 'text'); $form->append('Access To', 'role', 'text'); $form->append('User', 'user_id', 'hidden'); $form->append('File', 'name', 'file'); $form->append('Also add to', 'course_id', 'select', array('options' => $courses, 'attributes' => array('multiple' => 'multiple', 'name' => 'course_id[]'))); $form->append('Upload', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); $course = ORM::factory('course', $course_id); $roles = ORM::factory('role')->find_all()->as_array('id', 'name'); $view = View::factory('document/form')->bind('form', $form)->bind('course', $course)->bind('roles', $roles); Breadcrumbs::add(array('Courses', Url::site('course'))); Breadcrumbs::add(array('Documents', Url::site('document'))); Breadcrumbs::add(array('Upload', Url::site('document/upload'))); $this->content = $view; }
public function action_edit() { $id = $this->request->param('id'); if (!$id) { Request::current()->redirect('lecture'); } $lecture = ORM::factory('lecture', $id); $submitted = FALSE; if ($this->request->method() === 'POST' && $this->request->post()) { if (Arr::get($this->request->post(), 'save') !== null) { $data = Stickyform::ungroup_params($this->request->post()); $submitted = true; if ($this->validate($data)) { if ($this->request->post('type') == 'once') { $data['when'] = ''; $data['start_date'] = strtotime($data['once_date']) + $data['once_from'] * 60; $data['end_date'] = strtotime($data['once_date']) + $data['once_to'] * 60; } else { $date_range = $this->request->post('repeat'); $data['start_date'] = strtotime($date_range['from']); $data['end_date'] = strtotime($date_range['to']); $days = array(); foreach ($this->request->post('days') as $day => $value) { $time = $this->request->post(strtolower($day)); $days[$day] = $time['from'] . ':' . $time['to']; } $data['when'] = serialize($days); } $lecture = ORM::factory('lecture', $id); $lecture->values($data); $lecture->save(); $this->remove_events($lecture); $this->create_events(array_merge($this->request->post(), $data), $lecture); Request::current()->redirect('lecture'); exit; } } } $slider = array('once_slider' => array('from' => 420, 'to' => 660), 'monday_slider' => array('from' => 420, 'to' => 660), 'tuesday_slider' => array('from' => 420, 'to' => 660), 'wednesday_slider' => array('from' => 420, 'to' => 660), 'thursday_slider' => array('from' => 420, 'to' => 660), 'friday_slider' => array('from' => 420, 'to' => 660), 'saturday_slider' => array('from' => 420, 'to' => 660), 'sunday_slider' => array('from' => 420, 'to' => 660)); $saved_data = array('name' => $lecture->name, 'user_id' => $lecture->user_id, 'course_id' => $lecture->course_id, 'room_id' => $lecture->room_id, 'type' => $lecture->type); if ($lecture->type == 'once') { $saved_data = array_merge(array('once_date' => date('Y-m-d', $lecture->start_date), 'repeat_from' => '', 'repeat_to' => ''), $saved_data); $days = array(); $saved_slider = array('once_slider' => array('from' => ($lecture->start_date - strtotime(date('Y-m-d', $lecture->start_date))) / 60, 'to' => ($lecture->end_date - strtotime(date('Y-m-d', $lecture->end_date))) / 60)); } else { $saved_data = array_merge(array('once_date' => '', 'repeat_from' => date('Y-m-d', $lecture->start_date), 'repeat_to' => date('Y-m-d', $lecture->end_date)), $saved_data); $days = unserialize($lecture->when); $saved_slider = array(); foreach ($days as $day => $time) { $range = explode(':', $time); $saved_slider[strtolower($day) . '_slider'] = array('from' => $range[0], 'to' => $range[1]); } } $form = $this->form('lecture/edit/id/' . $id, $submitted, $saved_data); $slider = array_merge($slider, $saved_slider); $view = View::factory('lecture/form')->bind('form', $form)->bind('slider', $slider)->bind('days', $days); Breadcrumbs::add(array('Lectures', Url::site('lecture'))); Breadcrumbs::add(array('Edit', Url::site('lecture/edit/id/' . $id))); $this->content = $view; }
private function form($action, $submitted = false, $saved_data = array()) { $examgroups = array(); foreach (ORM::factory('examgroup')->find_all() as $examgroup) { $examgroups[$examgroup->id] = $examgroup->name; } $courses = array(); foreach (ORM::factory('course')->find_all() as $course) { $courses[$course->id] = $course->name; } $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('name' => '', 'examgroup_id' => '', 'course_id' => '', 'total_marks' => '', 'passing_marks' => '', 'date' => '', 'from' => '', 'to' => '', 'room_id' => '', 'reminder' => 1, 'reminder_days' => 2); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Name', 'name', 'text'); $form->append('Date', 'date', 'text', array('attributes' => array('class' => 'date'))); $form->append('From', 'from', 'hidden', array('attributes' => array('id' => 'slider-range_from'))); $form->append('To', 'to', 'hidden', array('attributes' => array('id' => 'slider-range_to'))); $form->append('Total Marks', 'total_marks', 'text'); $form->append('Passing Marks', 'passing_marks', 'text'); $form->append('Reminder', 'reminder', 'hidden', array('attributes' => array('id' => 'reminder'))); $form->append('Before', 'reminder_days', 'text', array('attributes' => array('size' => '1', 'maxlength' => '2', 'id' => 'reminder_days'))); $form->append('Grading Period', 'examgroup_id', 'select', array('options' => $examgroups)); $form->append('Room', 'room_id', 'select', array('options' => array())); $form->append('Course', 'course_id', 'select', array('options' => $courses)); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); return $form; }
private function form($action, $submitted = false, $saved_data = array()) { $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('title' => '', 'description' => ''); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Title', 'title', 'text'); $form->append('Description', 'description', 'textarea', array('attributes' => array('cols' => 50, 'rows' => 5))); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); $id = $this->request->param('id'); $sel_question = array(); if ($id != "") { $sel_question = Model_Flashcard::getQuestions($id); } $links = array('cancel' => Html::anchor('/flashcard/', 'or cancel'), 'click_here' => Html::anchor('/question/add/type/open', 'Click here')); $action = $this->request->action(); $course_id = Session::instance()->get('course_id'); $questions = Model_Flashcard::get_questions($course_id); $view = View::factory('flashcard/form')->bind('links', $links)->bind('form', $form)->bind('action', $action)->bind('id', $id)->bind('questions', $questions)->bind('selected_question', $sel_question); $this->content = $view; }
protected function form($action, $submitted = false, $saved_data = array()) { $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('title' => '', 'format' => 'quiz', 'description' => '', 'pub_status' => 1, 'time_minutes' => ''); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Exercise Title', 'title', 'text'); $form->append('Description', 'description', 'textarea', array('attributes' => array('class' => 'w70 ht120'))); $form->append('Format', 'format', 'select', array('options' => array('quiz' => 'Quiz Format', 'test' => 'Test Format'))); $form->append('Status', 'pub_status', 'select', array('options' => array(1 => 'Published', 0 => 'Unpublished'))); // $form->append('Resume Session?', 'session_resumable', 'select', array('options' => array(1 => 'Yes', 0 => 'No'))); $form->append('Time (in mins)', 'time_minutes', 'text'); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button r'))); $form->process(); return $form; }
private function form_changepassword($submitted = false, $u) { $action = 'auth/changepassword/u/' . $u; $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('password' => '', 'confirm_password' => ''); $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Password', 'password', 'password'); $form->append('Confirm Password', 'confirm_password', 'password'); $form->append('Submit', 'change_password', 'submit', array('attributes' => array('class' => 'button'))); $form->process(); return $form; }
protected function form($action, $submitted = false, $saved_data = array()) { $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('question' => '', 'extra' => '', 'course_id' => Session::instance()->get('course_id')); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Question', 'question', 'textarea', array('attributes' => array('class' => 'w70 ht120'))); $form->append('Extra Info', 'extra', 'textarea', array('attributes' => array('class' => 'w70 ht120'))); $courses = ORM::factory('course')->find_all()->as_array('id', 'name'); $form->append('Course', 'course_id', 'select', array('options' => $courses)); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button r'))); $form->process(); return $form; }
private function form($action, $submitted = false, $saved_data = array()) { $form = new Stickyform($action, array(), $submitted ? $this->_errors : array()); $form->default_data = array('name' => '', 'description' => '', 'access_code' => '', 'start_date' => date('Y-m-d'), 'end_date' => ''); $form->saved_data = $saved_data; $form->posted_data = $submitted ? $this->request->post() : array(); $form->append('Name', 'name', 'text'); $form->append('Description', 'description', 'textarea', array('attributes' => array('cols' => 50, 'rows' => 5))); $form->append('Access code', 'access_code', 'text'); $form->append('Start Date', 'start_date', 'text', array('attributes' => array('class' => 'date'))); $form->append('End Date', 'end_date', 'text', array('attributes' => array('class' => 'date'))); $form->append('Save', 'save', 'submit', array('attributes' => array('class' => 'button r'))); $form->process(); return $form; }