Skip to content

Enabling Autocomplete to return different values for lable and value #231

Open
@abhimanyuma

Description

@abhimanyuma

I don't see why the json returned always has to have the same value for label and value. A lot of actions would be simplified if I could return a column of my choosing (for e.g id) in the value field and search column in the label field.

def json_for_autocomplete(items, method, extra_data=[])
      items.collect do |item|
        hash = {"id" => item.id.to_s, "label" => item.send(method), "value" => item.send(method)}
        extra_data.each do |datum|
          hash[datum] = item.send(datum)
        end if extra_data
        # TODO: Come back to remove this if clause when test suite is better
        hash
      end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions