/** * Loads a form. The action (POST) depends on the purpose * @param string can be "update" or anything else */ public function load_form($purpose = null) { $this->form = midgardmvc_helper_forms::create('com_meego_comments_comment'); switch ($purpose) { case 'update': $action = $this->mvc->dispatcher->generate_url('comment_update', array('comment' => $this->object->guid), $this->request); break; case 'delete': $action = $this->mvc->dispatcher->generate_url('comment_delete', array('comment' => $this->object->guid), $this->request); break; default: $action = $this->mvc->dispatcher->generate_url('comment_create', array('to' => $this->data['parent']->guid), $this->request); } $this->form->set_action($action); if (array_key_exists('relocate', $_GET)) { $field = $this->form->add_field('relocate', 'text', false); $field->set_value($_GET['relocate']); $field->set_widget('hidden'); } else { if ($this->request->is_subrequest()) { // Comment posting form is in a dynamic_load, set parent URL for redirects $root_request = $this->mvc->context->get_request(0); $field = $this->form->add_field('relocate', 'text', false); $field->set_value($root_request->get_path()); $field->set_widget('hidden'); } } // Basic element information $field = $this->form->add_field('content', 'text'); $field->set_value($this->object->content); $widget = $field->set_widget('textarea'); $widget->set_css('content'); $widget->set_placeholder('Write your comment here'); }
public function load_form() { $this->form = midgardmvc_helper_forms::create('fi_openkeidas_diary_log'); $sport = $this->form->add_field('activity', 'integer'); $sport->set_value($this->object->activity); $sport_widget = $sport->set_widget('selectoption'); $sport_widget->set_label('Laji'); $sport_widget->set_options(fi_openkeidas_diary_activities::get_options()); $date = $this->form->add_field('date', 'datetime', true); $object_date = $this->object->date; if ($object_date->getTimestamp() <= 0) { $object_date->setTimestamp(time()); } $date->set_value($object_date); $date_widget = $date->set_widget('date'); $date_widget->set_label('Päivämäärä'); $duration = $this->form->add_field('duration', 'float', true); $duration->set_value($this->object->duration); $duration_widget = $duration->set_widget('number'); $duration_widget->set_label('Aika tunteina (esim. 0.5)'); $distance = $this->form->add_field('distance', 'float'); $distance->set_value($this->object->distance); $distance_widget = $distance->set_widget('number'); $distance_widget->set_label('Kilometrit (esim. 3.5)'); $location = $this->form->add_field('location', 'text'); $location->set_value($this->object->location); $location_widget = $location->set_widget('text'); $location_widget->set_label('Paikka'); $comment = $this->form->add_field('comment', 'text'); $comment->set_value($this->object->comment); $comment_widget = $comment->set_widget('textarea'); $comment_widget->set_label('Lisätiedot'); }
private function generate_form() { $form = midgardmvc_helper_forms::create('fi_openkeidas_registration_forgot'); $field = $form->add_field('email', 'email', true); $widget = $field->set_widget('email'); $widget->set_label('Sähköpostiosoite'); return $form; }
public static function create(midgard_object $object) { $form_namespace = get_class($object); if ($object->guid) { $form_namespace = $object->guid; } $form = midgardmvc_helper_forms::create($form_namespace); midgardmvc_helper_forms_mgdschema::object_to_form($object, $form); return $form; }
public function get_search(array $args) { midgardmvc_core::get_instance()->authorization->require_user(); $this->data['form'] = midgardmvc_helper_forms::create('fi_openkeidas_groups_search'); $this->data['form']->set_method('get'); $search = $this->data['form']->add_field('search', 'text'); $search_widget = $search->set_widget('text'); $search_widget->set_label('Hae ryhmiä'); $this->data['search_groups'] = array(); if (!isset($_GET['search']) || empty($_GET['search'])) { return; } $search->set_value($_GET['search']); $qb = new midgard_query_builder('fi_openkeidas_groups_group'); $qb->add_constraint('title', 'LIKE', "{$_GET['search']}%"); $qb->add_order('metadata.score', 'DESC'); $this->data['groups'] = array_map('fi_openkeidas_groups_controllers_groups::add_members_for_group', $qb->execute()); }
public function load_form() { $this->form = midgardmvc_helper_forms::create('fi_openkeidas_diary_challenge'); $title = $this->form->add_field('title', 'text', true); $title->set_value($this->object->title); $title_widget = $title->set_widget('text'); $title_widget->set_label('Haaste'); $group_options = array(); foreach ($this->data['user_groups'] as $group) { $group_options[] = array('description' => $group->title, 'value' => $group->id); } $challenger = $this->form->add_field('challenger', 'integer'); $challenger->set_value($this->object->challenger); $challenger_widget = $challenger->set_widget('selectoption'); $challenger_widget->set_label('Haastaja'); $challenger_widget->set_options($group_options); $sport = $this->form->add_field('activity', 'integer'); $sport->set_value($this->object->activity); $sport_widget = $sport->set_widget('selectoption'); $sport_widget->set_label('Laji'); $options = fi_openkeidas_diary_activities::get_options(); array_unshift($options, array('description' => 'Kaikki', 'value' => '')); $sport_widget->set_options($options); $start = $this->form->add_field('start', 'datetime', true); $object_start = $this->object->start; if ($object_start->getTimestamp() <= 0) { $object_start->setTimestamp(time()); } $start->set_value($object_start); $start_widget = $start->set_widget('date'); $start_widget->set_label('Haaste alkaa'); $end = $this->form->add_field('enddate', 'datetime', true); $object_end = $this->object->enddate; if ($object_end->getTimestamp() <= 0) { $new_end = new DateTime('last day of next month'); $object_end->setTimestamp($new_end->getTimestamp()); } $end->set_value($object_end); $end_widget = $end->set_widget('date'); $end_widget->set_label('Haaste päättyy'); }
/** * Load the form, set defaults */ public function load_form() { $this->form = midgardmvc_helper_forms::create('com_meego_ratings_rating'); $this->prepare_form(); }
private function load_form() { $this->form = midgardmvc_helper_forms::create('fi_openkeidas_diary_stats'); $weight = $this->form->add_field('weight', 'float'); $weight->set_value($this->data['stats']['weight']); $weight_widget = $weight->set_widget('number'); $weight_widget->set_label('Paino'); $weight_widget->set_placeholder('Paino (kg)'); $height = $this->form->add_field('height', 'float'); $height->set_value($this->data['stats']['height']); $height_widget = $height->set_widget('number'); $height_widget->set_label('Pituus'); $height_widget->set_placeholder('Pituus (cm)'); $bmi = $this->form->add_field('bmi', 'float'); $bmi->set_value($this->data['stats']['bmi']); $bmi->set_readonly(true); $bmi_widget = $bmi->set_widget('number'); $bmi_widget->set_label('BMI'); $cooper = $this->form->add_field('cooper', 'float'); $cooper->set_value($this->data['stats']['cooper']); $cooper_widget = $cooper->set_widget('number'); $cooper_widget->set_label('Cooper'); $height_widget->set_placeholder('Cooperin testi (metriä juostu 12 minuutissa)'); $vo2max = $this->form->add_field('vo2max', 'float'); $vo2max->set_value($this->data['stats']['vo2max']); $vo2max_widget = $vo2max->set_widget('number'); $vo2max_widget->set_label('Maksimi hapenottokyky'); $vo2max_widget->set_placeholder('Maksimi hapenottokyky (cooperin testin mukaan)'); }
public function load_form() { $this->form = midgardmvc_helper_forms::create('fi_openkeidas_groups_group'); $title = $this->form->add_field('title', 'text', true); $title_widget = $title->set_widget('text'); $title_widget->set_label('Nimi'); }