# action

## Overview

With the use of a nested `action` in an `edit-typeahead` an additional item will appear with the results of [`on-search`](https://docs.journeyapps.com/reference/build/ui-components/all-ui-components/object-table/column/edit-typeahead/..#on-search). If this item is selected, this `action` tag's [`on-press`](#on-press) will fire with the current search value.

### Basic Example

In this example we add the option to create a new user.

{% code title="main.view\.xml" %}

```xml
<object-table ...>
  <column ...>
    <edit-typeahead ...>
      <action label="Create User" icon="fa-user" on-press="$:createUser($object, searchValue)" />
    </edit-typeahead>
  </column>
</object-table>
```

{% endcode %}

{% code title="main.js" %}

```javascript
function createUser(object, searchValue){
    var user = DB.user.create();
    user.name = searchValue;
    user.save();
}
```

{% endcode %}

![](https://2865107717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9TCHLR67eLHBOjPvHhud%2Fuploads%2Fgit-blob-79346d7abb4859497407adef91245380e8e3dfb2%2Fedit-typeahead-action-example.png?alt=media)

## Standard Attributes

### `label`

**Optional**

**Type**: `string` (static text, a [format string](https://docs.journeyapps.com/reference/app-features/xml-format-strings) or the return value of a [JS/TS function](https://docs.journeyapps.com/reference/app-features/calling-js-functions-from-xml))

**Default**: unset

The text to display on the `action` item.

### `on-press`

**Required**

{% content-ref url="../../../../xml-fields/on-press" %}
[on-press](https://docs.journeyapps.com/reference/build/ui-components/xml-fields/on-press)
{% endcontent-ref %}

### `validate`

**Optional**

**Type**: `boolean`

**Default**: `false`

Set to `true` to ensure that no required input fields in the current view are empty before performing the [`on-press`](#on-press) action.

```xml
<action on-press="$:createUser($object, searchValue)" validate="true" />
```

## Advanced Attributes

### `icon`

**Optional**

**Type**: `string`

**Default**: `fa-circle-plus`

The icon to display on the button, it will be placed on the left of the label by default. The icon can be a [Font Awesome icon](https://docs.journeyapps.com/reference/build/ui-components/icons#font-awesome-icons) or an [Ionicons icon](https://docs.journeyapps.com/reference/build/ui-components/icons#ionicons-icons).

```xml
<action icon="fa-user" on-press="$:createUser($object, searchValue)" />
```
