Intro
Ajax.InPlaceCollectionEditor allow user dynamicaly (in-place) choose options from select DOM element instead of input or textarea using input_in_place_editor_tag helper.
How to use
There are several new options for input_in_place_editor_tag.
collection array List of options to display (key => value)
value int Initially selected value
If option collection is set, collection mode is activated.
Also, developer can redefine some strings via options in both modes:
click_to_edit_text
loading_text
saving_text
Modification
1) Change line 817
<?php
...
$javascript = "new Ajax.InPlaceEditor(";
...
to
<?php
...
$javascript = sprintf( "new Ajax.InPlace%sEditor(",
(isset($options['collection'])) ? 'Collection' : '' );
...
2) Add new lines after line 865(871)
<?php
...
if (isset($options['click_to_edit_text']))
{
$js_options['clickToEditText'] = "'".$options['click_to_edit_text']."'";
}
if (isset($options['loading_text']))
{
$js_options['loadingText'] = "'".$options['loading_text']."'";
}
if (isset($options['saving_text']))
{
$js_options['savingText'] = "'".$options['saving_text']."'";
}
if (isset($options['empty_text']))
{
$js_options['emptyText'] = "'".$options['empty_text']."'";
}
if (isset($options['collection']))
{
$str = '';
foreach( $options['collection'] as $key => $value )
{
if(!empty($str)) $str .= ',';
$str .= sprintf("[%d, '%s']", $key, $value );
}
$js_options['collection'] = "[$str]";
}
if (isset($options['value']))
{
$js_options['value'] = sprintf( '%d', $options['value']);
}
...