Project

General

Profile

Actions

Feature #8178

open

Allow setting attributes for form elements in package XML

Added by Michael Newton over 6 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Package System
Target version:
-
Start date:
12/09/2017
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:

Description

I'd like to suggest a couple of enhancements that would make package interfaces easier to work with when enhancing them with JavaScript.

Given a couple of typical form elements in the package XML:

    <field>
        <fielddescr>Description</fielddescr>
        <fieldname>desc</fieldname>
        <description>Enter a description for this item.</description>
        <type>input</type>
        <size>70</size>
    </field>
    <field>
        <fielddescr>Setting</fielddescr>
        <fieldname>sett</fieldname>
        <description>Enable a setting for this item.</description>
        <type>checkbox</type>
    </field>

The only way to work with them via JavaScript is by name/id:

$("input#desc").attr("disable", false);
$("input#sett").attr("disabled", false);

Not terrible, but it can be very wasteful to create a dozen new jQuery instances to enable some elements. It would be nice to be able to specify a class name:

    <field>
        <fielddescr>Description</fielddescr>
        <fieldname>desc</fieldname>
        <description>Enter a description for this item.</description>
        <type>input</type>
        <size>70</size>
        <class>enable_me</class>
    </field>
    <field>
        <fielddescr>Setting</fielddescr>
        <fieldname>sett</fieldname>
        <description>Enable a setting for this item.</description>
        <type>checkbox</type>
        <class>enable_me</class>
    </field>

And then we can work with that:

$(".enable_me").attr("disable", false);

Another feature that could be useful is the ability to use data attributes (https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes). XML like this:

    <field>
        <fielddescr>Description</fielddescr>
        <fieldname>desc</fieldname>
        <description>Enter a description for this item.</description>
        <type>input</type>
        <size>70</size>
        <class>enable_me</class>
        <data>
            <entry name="field1" value="foo"/>
            <entry name="field2" value="bar"/>
        </data>
    </field>

Might produce HTML like this:

<input type="text" name="desc" id="desc" class="enable_me" data-field1="foo" data-field2="bar"/>
Actions #1

Updated by Anonymous over 6 years ago

Good suggestions. The package manager XML thing is something of a nightmare to work on, but this might not be too bad.

Actions

Also available in: Atom PDF