Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31677

Class moodleform should support underlying QuickForm->toHtml()

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Duplicate
    • Minor
    • None
    • 2.1, 2.2, 2.2.1
    • Forms Library
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • Hide

      The current workaround is using reflection to retrieve the protected {_form} property. This is a nasty hack.

      $reflect = new ReflectionClass('my_moodleform');
      $form_field = $reflect->getPropert('_form');
      $form_field->setAccessible(true);
       
      $html = $form_field->getValue($form)->toHtml();

      Show
      The current workaround is using reflection to retrieve the protected { _form } property. This is a nasty hack. $reflect = new ReflectionClass('my_moodleform'); $form_field = $reflect->getPropert('_form'); $form_field->setAccessible(true);   $html = $form_field->getValue($form)->toHtml();
      • Make a form definition.
      • Try rendering echo $form->html(); or $form->display();
      • Behavior should be the same.

    Description

      There are cases where the developer needs the form html instead of immediate display. This behavior would be consistent with $OUTPUT and html_writer.

      // Returns html of form
      $html = $form->html();

      I have included a patch that adds this behavior.

      Attachments

        Issue Links

          Activity

            People

              moodle.com Moodle HQ
              pcali1 Philip Cali
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: