Example #1
0
 /**
  * Loads a form
  */
 public function load_form()
 {
     $this->form = midgardmvc_helper_forms_mgdschema::create($this->object, false, 'label_device_', 'tip_device_');
     $this->form->set_submit('form-submit', $this->mvc->i18n->get('command_save'));
     # remove the name field, we will genarate it from title
     $this->form->__unset('name');
     # change the default widget of provider field
     $providers = com_meego_devprogram_provutils::get_providers_of_current_user();
     foreach ($providers as $provider) {
         $provider_options[] = array('description' => $provider->title, 'value' => $provider->id);
     }
     $provider = new midgardmvc_helper_forms_field_integer('provider', true);
     $provider->set_value($this->object->provider);
     $widget = $provider->set_widget('selectoption');
     $widget->set_label($this->mvc->i18n->get('label_device_provider'));
     if (is_array($provider_options)) {
         $widget->set_options($provider_options);
     }
     $this->form->__set('provider', $provider);
     # change the default widget of platform field
     $platforms = $this->mvc->configuration->platforms;
     foreach ($platforms as $key => $title) {
         $platform_options[] = array('description' => $title, 'value' => $key);
     }
     $platform = new midgardmvc_helper_forms_field_text('platform', true);
     $platform->set_value($this->object->platform);
     $widget = $platform->set_widget('selectoption');
     $widget->set_label($this->mvc->i18n->get('label_device_platform'));
     if (is_array($platform_options)) {
         $widget->set_options($platform_options);
     }
     $this->form->__set('platform', $platform);
 }
Example #2
0
 public function load_form()
 {
     $this->form = midgardmvc_helper_forms_mgdschema::create($this->object, false);
     if (!$this->object->guid) {
         unset($this->form->url);
     }
 }
Example #3
0
 /**
  * Loads a form
  */
 public function load_form()
 {
     $this->form = midgardmvc_helper_forms_mgdschema::create($this->object, false, 'label_program_', 'tip_program_');
     # we have to alter the submit button and three fields on the form
     $this->form->set_submit('form-submit', $this->mvc->i18n->get('command_save'));
     # remove the name field, we will genarate it from title
     $this->form->__unset('name');
     # change the default widget of duedate field
     $object_end = $this->object->duedate;
     if ($object_end->getTimestamp() <= 0) {
         $new_end = new DateTime('last day of next month');
         $object_end->setTimestamp($new_end->getTimestamp());
     }
     $duedate = new midgardmvc_helper_forms_field_text('duedate', true);
     $duedate->set_value($object_end);
     $widget = $duedate->set_widget('date');
     $widget->set_label($this->mvc->i18n->get('label_program_duedate'));
     $this->form->__set('duedate', $duedate);
     # change the default widget of device field
     $devices = com_meego_devprogram_devutils::get_devices_of_current_user();
     foreach ($devices as $device) {
         $device_options[] = array('description' => $device->title, 'value' => $device->id);
     }
     $device = new midgardmvc_helper_forms_field_integer('device', true);
     $device->set_value($this->object->device);
     $widget = $device->set_widget('selectoption');
     $widget->set_label($this->mvc->i18n->get('label_program_device'));
     if (is_array($device_options)) {
         $widget->set_options($device_options);
     }
     $this->form->__set('device', $device);
 }
 /**
  * Loads a form
  */
 public function load_form()
 {
     $this->form = midgardmvc_helper_forms_mgdschema::create($this->object, false, 'label_provider_', 'tip_provider_');
     $this->form->set_submit('form-submit', $this->mvc->i18n->get('command_save'));
     # remove the name field, we will genarate it from title
     $this->form->__unset('name');
 }
 /**
  * Loads the judging form
  */
 public function load_judge_form()
 {
     $this->form = midgardmvc_helper_forms_mgdschema::create($this->object, false, 'label_application_', 'tip_application_');
     $this->form->set_submit('form-submit', $this->mvc->i18n->get('command_submit'), true);
     # remove the program field
     $this->form->__unset('program');
     # remove fields that are not needed by judges
     $this->form->__unset('title');
     $this->form->__unset('summary');
     $this->form->__unset('plan');
     $this->form->__unset('project');
     $this->form->__unset('team');
     $this->form->__unset('url');
     $this->form->__unset('status');
     $field = $this->form->add_field('program', 'integer', false);
     $field->set_value($this->object->program);
     $field->set_widget('hidden');
     # checkbox for the decision
     $field = $this->form->add_field('status', 'integer', false);
     $widget = $field->set_widget('radiobuttons');
     $widget->add_label($this->mvc->i18n->get('label_application_decision'));
     $options = array(array('description' => $this->mvc->i18n->get('label_application_decision_approve'), 'value' => CMD_APPLICATION_APPROVED), array('description' => $this->mvc->i18n->get('label_application_decision_moreinfo'), 'value' => CMD_APPLICATION_MOREINFO), array('description' => $this->mvc->i18n->get('label_application_decision_deny'), 'value' => CMD_APPLICATION_DENIED));
     $widget->set_options($options);
     // pimp the date input fields
     $this->mvc->head->add_jsfile(MIDGARDMVC_STATIC_URL . '/' . $this->component . '/js/decision.js');
 }
 private function generate_form(fi_openkeidas_registration_user $user)
 {
     $form = midgardmvc_helper_forms_mgdschema::create($user, false);
     // Set labels
     $form->firstname->widget->set_label('Etunimi');
     $form->lastname->widget->set_label('Sukunimi');
     $form->memberid->widget->set_label('OAJ:n jäsennumero');
     $form->email->widget->set_label('Sähköposti');
     $form->school->widget->set_label('Koulu');
     $form->municipality->widget->set_label('Kunta');
     // Set all fields to required
     foreach ($form->items as $item) {
         $item->set_required(true);
     }
     return $form;
 }
Example #7
0
 public function process_form()
 {
     $this->data['form']->process_post();
     midgardmvc_helper_forms_mgdschema::form_to_object($this->data['form'], $this->object);
 }
 public static function form_to_object(midgardmvc_helper_forms_group $form, $object)
 {
     // Go through form items and fill the object
     $items = $form->items;
     foreach ($items as $key => $item) {
         if (!property_exists($object, $key)) {
             // The object has no such property
             continue;
         }
         if ($item instanceof midgardmvc_helper_forms_group && $key == 'metadata') {
             midgardmvc_helper_forms_mgdschema::form_to_object($item, $object->metadata);
             continue;
         }
         $object->{$key} = $item->get_value();
     }
 }
Example #9
0
 public function post_update(array $args)
 {
     $this->get_update($args);
     try {
         $this->data['form']->process_post();
         midgardmvc_helper_forms_mgdschema::form_to_object($this->data['form'], $this->object);
         $this->object->update();
         // FIXME: We can remove this once signals work again
         midgardmvc_core::get_instance()->cache->invalidate(array($this->object->guid));
         // TODO: add uimessage of $e->getMessage();
         midgardmvc_core::get_instance()->head->relocate($this->get_url_read());
     } catch (midgardmvc_helper_forms_exception_validation $e) {
         // TODO: UImessage
     }
 }