fields.className

fields.className

Karl53Karl53 Posts: 72Questions: 29Answers: 0
edited August 2015 in Editor

Editor v1.4.2 with Bootstrap v3.3.4. Inline.

It appears that fields.className does not add a class to the field container. Or at least not where I would expect it with Bootstrap.

Debugger shows:

<input class="form-control" id="amt1" type="text" maxlength="14">

I expect to see this:

<input class="form-control my-class" id="amt1" type="text" maxlength="14">

Assuming this:

    {
        "name": "fltAmount1",
        "type": "text",
        "attr": {"maxlength": 14},
        "className": "my-class",
        "id": "amt1"
    },

Is this a bug, or am I expecting the wrong thing?

Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    The class name is added to the field wrapper (which the documentation refers to as the "container") rather than the input element itself. For that you could use the attr option:

    "attr": {
      "maxlength": 14,
      "class": "my-class"
    },
    

    The other option is to use the field().input() method to get the node and use $().addClass().

    Allan

This discussion has been closed.