# Manually saving data

### FieldFoo::make('Foo')->custom()

If you want to be in control of how a field is saved add the `custom()` method to the field

```
    Input::make('My custom field', 'foo')
      ->custom()
      ->rule('required'),
```

### FieldFoo::make('Foo')->relation()

The `relation()` method does the same as `custom()`, it is just there for code readability&#x20;

```
    Select::make('Parent', 'parent_id')
      ->relation()
      ->rule('required'),
```

## saveFoo() - save the data

If you used the `custom()` or `relation()` method on your field, it will be excluded from the default save method, so **you must save them yourself** via the `saveFoo()` hook.

The method is executed **AFTER field validation** and **AFTER** the **model is created or updated,** meaning that you have access to `$this->model` even if it is a `create` form.

```php
protected function saveFoo($validated_field_value)
{
    //the validate field value is passed to the hook
    $field_value = $validated_field_value;
    
    //or get the field value via the fields name property
    $field_value = $this->foo;
    
    //or via form_data
    $field_value = data_get($form_data, 'foo');
    
    //save the data
    $this->model->foo = $field_value;
}
```

**You do NOT have to prefix with `FormData`**

* Example method name for an array field `form_data.people.name` will become `savePeopleName($validated_value)`
* Example method name for `form_data.some_field_name` will become `saveSomeFieldName($validated_value)`

Example; `form_data.price`&#x20;

```php
public function savePrice($validated_value)
{
    $this->model->price = $validated_value;
    $this->model->save();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tina-hammar.gitbook.io/tall-forms/concept/manually-saving-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
