Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-5367

Dataform field - default content.

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8
    • Fix Version/s: 2.7.3, 2.8
    • Component/s: Set: Dataform
    • Labels:
      None
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE

      Description

      The purpose of issue is to normalize dataform field support for default content that can be populated to the field input element in the entry form.
      This includes also adjustment of the menu fields support and adding support to the text and text area fields.

      • DB support
        • Two additional database columns in the dataform_fields table:
          • defaultcontentmode: Whether default content is populated only in new entries or in any entry.
          • defaultcontent: The default content.
        • Upgrade.
      • Backup/restore support.
      • API
        • dataformfield::content_names() - Existing; needs to have public visibility.
        • dataformfield::content_is_empty() - Existing; needs to have public visibility.
        • dataformfieldform::definition_default_settings() - New; wrapper for the content definition settings.
        • dataformfieldform::get_data_default_content() - New; prepares the default content form data for DB; the return value will be assigned to the field's defaultcontent attribute in the get_data method.
        • dataformfieldform::validation_default_content() - New; validate the default content setting where applicable (e.g. the default content of the select field must be one of the field's options).
      • Lang strings.

      Adding field support requires at least the following:

      • Field form:
        • Implement dataformfield_<type>_form::definition_default_content().
        • (Optional) Implement dataformfield_<type>_form::data_preprocessing() if you need to convert the field defaultcontent data to the form definition elements data.
        • Implement dataformfield_<type>_form::get_data_default_content() to convert the form data to storable data which will be assigned to the defaultcontent attribute.
      • Field renderer:
        • Add content check in the dataformfield_<type>_renderer::display_edit() (or equivalent) method.
      • Field class:
        • (Optional) Implement dataformfield_<type>_<type>::get_defaultcontent() if you need to convert the stored content to workable content (e.g unserialize).
      • Tests:
        • Add \dataformfield\<type>\test\behat\defaultcontent class.

        Attachments

          Activity

            People

            • Assignee:
              itamart Itamar Tzadok
              Reporter:
              itamart Itamar Tzadok
              Tester:
              Itamar Tzadok
              Participants:
              Component watchers:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Nov/14