コード例 #1
0
    public function render($name, $value = null, $attributes = array(), $errors = array())
    {
        $size = isset($attributes['size']) ? $attributes['size'] : (isset($this->attributes['size']) ? $this->attributes['size'] : 10);
        $letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
        $text = '<div class="dcFinder">';
        $id = $this->generateId($name);
        $id_left = $id . '_left';
        $unassociated_name = 'unassociated_' . $id;
        $double_list = new sfWidgetFormSelectDoubleList(array('choices' => $this->getOption('choices')));
        $double_list->setOptions($this->getOptions());
        $custom_handler = $this->getOption('custom_handler');
        $widget_serialized = base64_encode(serialize($double_list));
        $text .= '<ul class="finder">';
        foreach ($letters as $letter) {
            $text .= '<li>';
            $text .= link_to_function($letter, remote_function(array('url' => '@dcWidgetFormSelectDoubleListFinderPropel', 'with' => "'?letter=" . $letter . "&size=" . $size . "&name=" . $unassociated_name . "&values=" . base64_encode(serialize($value)) . ($custom_handler ? "&custom_handler=" . base64_encode(serialize($custom_handler)) : '') . "&widget=" . $widget_serialized . "'", 'before' => "\$('{$id}_indicator').show(); dcFinder.setCurrent('{$id}', this);", 'complete' => "\$('{$id}_indicator').hide();", 'update' => $id_left)));
            $text .= '</li>';
        }
        $text .= '<li class="current">';
        $text .= link_to_function(__('All'), remote_function(array('url' => '@dcWidgetFormSelectDoubleListFinderPropel', 'with' => "'?letter=" . "&size=" . $size . "&values=" . base64_encode(serialize($value)) . ($custom_handler ? "&custom_handler=" . base64_encode(serialize($custom_handler)) : '') . "&name=" . $unassociated_name . "&widget=" . $widget_serialized . "'", 'update' => $id_left, 'before' => "\$('{$id}_indicator').show(); dcFinder.setCurrent('{$id}', this);", 'complete' => "\$('{$id}_indicator').hide();")));
        $text .= '</li>';
        $text .= '<li style="display: none;" id="' . $id . '_indicator">' . $this->getOption('loader') . '</li>';
        $text .= '</ul>';
        $this->addOption('template', <<<EOF
  <div class="%class%">
    <div style="float: left">
      <div class="double_list_label">%label_unassociated%</div>
      <div id="{$id_left}">%unassociated%</div>
    </div>
    <div style="float: left; margin-top: 2em">
      %associate%
    <br />
      %unassociate%
  </div>
  <div style="float: left">
    <div class="double_list_label">%label_associated%</div>
      %associated%
    </div>
    <br style="clear: both" />
    <script type="text/javascript">
      sfDoubleList.init(document.getElementById('%id%'), '%class_select%');
    </script>
  </div> 
EOF
);
        $text .= parent::render($name, $value, $attributes, $errors);
        $text .= '</div>';
        return $text;
    }