I have a TestField (Single line of text) that I can return a value to while in NewForm.aspx. The problem being, the TextBox disappears and it only displays the returned text itself.

(function () {
   var ctx = {};
   ctx.Templates = {};
   ctx.Templates.Fields = {
       'TestField': { 'NewForm': renderTestField }


function renderTestField(ctx)
   return 'TestText';

   //Will the below code work with a custom value in it??
   //return <input type="text" value="" maxlength="255" id="Dig_x0020_ID_b5482683-9113-41be-b2ea-8095919a2fd4_$TextField" title="Dig ID" class="ms-long ms-spellcheck-true">

I would like to return the text inside the original TextBox so the user can still edit it. What should my renderTextField function look like?

Should I return the original HTML which is being rendered? Do I need the long ID?

EDIT: I tried returning the Original <input> HTML from the JSLink, but it doesn't save to the List Item

1 Answer 1


Try as below

function renderTestField(ctx) {
    ctx.CurrentFieldValue = "TestText";
    return SPFieldText_Edit(ctx);

You can set custom value as below also

function renderTestField(ctx) {
    return '<input type="text" maxlength="255" id="Dig_x0020_ID_b5482683-9113-41be-b2ea-8095919a2fd4_$TextField" title="Dig ID" class="ms-long ms-spellcheck-true" value="TestValue"/>';
  • I tried this with multiple fields. Doesn't work :( May 11, 2015 at 19:04
  • Textbox shows up, value is not applied. The value attribute is empty in the markup May 11, 2015 at 19:08
  • If I use ctx.CurrentItem["TestField"] = 1, I can see this being set in my watch window but the field doesn't grab it May 11, 2015 at 19:21
  • :) :) :) This solved multiple issues in one. Thanks once again Amal! May 11, 2015 at 19:25
  • 1
    I think it is SPFieldNote_Edit May 11, 2015 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.