{live:item_id:field_id:required:function:widget_type:widget_properties}

Description

Renders one field of an item as an in-place (live) editable widget that saves by itself the moment the editor leaves the field, with no full page reload and no surrounding form. Point it at an item id and a field id; on a published page the field shows its current value as an editable input, and an onchange handler posts the new value back over AJAX. Use the optional required, function (a JavaScript callback run after a successful save), widget_type (a 3-letter widget code such as sel or dte to override the field default) and widget_properties (a JSON object configuring that widget) parameters for finer control. Pass an empty item_id to edit the field of the current item in a loop (write _#ITEM_ID_ to be explicit). Live editing only renders for a logged-in editor with write permission and the aa-jslib script loaded; for an anonymous visitor, or an unknown item or field, it renders nothing. Related: edit and editfull render the same widget in form style, ajax gives a click-to-open inline editor, and input renders a widget for a brand-new item.

Parameters

item_id required

Id of the item whose field you want to edit. Use a field-getter such as 84fe317799e71d1c932ce6a7180db86c inside a view or loop. Leave empty to target the current item being rendered.

field_id required

Id of the field to edit, e.g. headline........ or text...........2. The widget shown matches that field's configured input unless you override it with widget_type.

required optional default empty (not required)

Set to 1 to mark the live field as required (adds the required flag to the widget). Default unset means not required.

function optional default empty

JavaScript callback run after a successful save (passed to AA_SendWidgetLive). Use it to react to the change, e.g. location.reload() to refresh the page. Default: none.

widget_type optional default the field's configured widget

Three-letter widget code to override the field default input, e.g. sel for a select, dte for a date picker, chb for a checkbox. Default: the field's own configured widget.

widget_properties optional default empty

JSON object configuring the chosen widget, e.g. {"const_arr":{"0":"no","1":"yes"}} for a select or {"show_time":"1"} for a date widget. Default: none.

Examples

virtual{live:5726c2c6b035d7aab450d1794e9e90d7:headline........}
Expected(an editable input pre-filled with the field value, e.g. Gamma, that auto-saves on blur)
Actual
Save
virtual{live:5726c2c6b035d7aab450d1794e9e90d7:headline........:1}
Expected(the same live input, flagged required so an empty value is rejected on save)
Actual
Save
test[{live:}]
Expected[]
Actual[]
virtual{live:5726c2c6b035d7aab450d1794e9e90d7:headline........:::sel:{"const_arr":{"0":"no","1":"yes"}}}
Expected(a live drop-down with options no and yes instead of the field default input)
Actual
Save
virtual{live:5726c2c6b035d7aab450d1794e9e90d7:headline........::function() { location.reload(); }}
Expected(a live input whose successful save runs the callback, here reloading the page; pass an empty item id to bind it to the current row inside a view loop)
Actual
Save
test[{live:5726c2c6b035d7aab450d1794e9e90d7:nosuchfield000000}]
Expected[]
Actual[]
test[{live:00000000000000000000000000000000:headline........}]
Expected[]
Actual[]