Welcome to the Cookbook

loading...
Please login to continue

7.1.2.12 editor

editor(string $id, string $url, array $options)

Creates an in-place editor at DOM id. The supplied $url should be an action that is responsible for saving element data. For more information and demos see http://github.com/madrobby/scriptaculous/wikis/ajax-inplaceeditor.

Common options might include:

$options keys Description

$options['collection']

Activate the 'collection' mode of in-place editing. $options['collection'] takes an array which is turned into options for the select. To learn more about collection see http://github.com/madrobby/scriptaculous/wikis/ajax-inplacecollectioneditor.

$options['callback']

A function to execute before the request is sent to the server. This can be used to format the information sent to the server. The signature is function(form, value)

$options['okText']

Text of the submit button in edit mode

$options['cancelText']

The text of the link that cancels editing

$options['savingText']

The text shown while the text is sent to the server

$options['formId']

$options['externalControl']

$options['rows']

The row height of the input field

$options['cols']

The number of columns the text area should span

$options['size']

Synonym for ‘cols’ when using single-line

$options['highlightcolor']

The highlight color

$options['highlightendcolor']

The color which the highlight fades to

$options['savingClassName']

$options['formClassName']

$options['loadingText']

$options['loadTextURL']

Example

<div id="in_place_editor_id">Text To Edit</div>
<?php
echo $ajax->editor( 
    "in_place_editor_id", 
    array( 
        'controller' => 'Posts', 
        'action' => 'update_title',
        $id
    ), 
    array()
);
?>
  1. <div id="in_place_editor_id">Text To Edit</div>
  2. <?php
  3. echo $ajax->editor(
  4. "in_place_editor_id",
  5. array(
  6. 'controller' => 'Posts',
  7. 'action' => 'update_title',
  8. $id
  9. ),
  10. array()
  11. );
  12. ?>