Document toolboxDocument toolbox

Function instantedit()

The instantedit() function is available in the design.php-script and provides a quick inline editor for changing a Record2 field, without the need to go to a special edit screen.


Example

To display the deadline of a given task:

$todo = new Todo();
$todo->fromDB(1);
echo '<b>Deadline: </b>'.$todo->gvd('tdeadline');

If one wants to use the instantedit function to make the deadline editable, one can do this:

$todo = new Todo();
$todo->fromDB(1);
echo '<b>Deadline: </b>'.instantedit($todo->gvd('tdeadline'), 'Todo', 1, 'tdeadline', chp('todo_edit'));

This will make the deadline clickable and give the user a chance to edit it inline.


Limitations

The function will yield a basic edit field of an appropriate type, but will not impose any restrictions on such a field, so if a Person-field is needed and this field needs to be limited to only display persons from a given Customer-object, then the instantedit() function isn't able to impose such a limitation automatically.