https://github.com/sjelfull/airtable
Sweet saving and fetching of data with Airtable
https://github.com/sjelfull/airtable
craft-plugin craftcms craftcms-plugin
Last synced: 12 months ago
JSON representation
Sweet saving and fetching of data with Airtable
- Host: GitHub
- URL: https://github.com/sjelfull/airtable
- Owner: sjelfull
- License: mit
- Created: 2017-04-28T14:20:20.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-29T13:10:11.000Z (about 9 years ago)
- Last Synced: 2025-04-11T00:29:41.984Z (about 1 year ago)
- Topics: craft-plugin, craftcms, craftcms-plugin
- Language: PHP
- Size: 147 KB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Airtable plugin for Craft CMS
Sweet saving and fetching of data with [Airtable](https://airtable.com/invite/r/znUACjay)

## Installation
To install Airtable, follow these steps:
1. Download & unzip the file and place the `airtable` directory into your `craft/plugins` directory
2. Install plugin in the Craft Control Panel under Settings > Plugins
3. The plugin folder should be named `airtable` for Craft to see it.
Airtable works on Craft 2.4.x and Craft 2.5.x.
## Airtable Overview
[Airtable](https://airtable.com/invite/r/znUACjay) is a human-friendly database solution that makes it super easy to manage both simple and complex, relational data.
## Configuring Airtable
```php
'',
// Find this on https://airtable.com/api
'base'
=> '',
// The name of the table. Make sure the capitalization is correct
'table' => '',
// Allowed field keys. This matches the field names in the table
'allowedFields' => [ ],
];
```
## Using Airtable
_Example form_
```twig
{{ getCsrfInput() }}
{% macro errorList(errors) %}
{% if errors %}
- {{ error }}
{% for error in errors %}
{% endfor %}
{% endif %}
{% endmacro %}
{% from _self import errorList %}
{# Display server error #}
{% if airtable is defined %}
{{ errorList(airtable.getErrors('server')) }}
{% endif %}
Name
{% if airtable is defined %}
{{ errorList(airtable.getErrors('Name')) }}
{% endif %}
E-mail
{% if airtable is defined %}
{{ errorList(airtable.getErrors('E-mail')) }}
{% endif %}
Notes
{%- if airtable is defined %}{{ airtable.Notes }}{% endif -%}
{% if airtable is defined %}
{{ errorList(airtable.getErrors('Notes')) }}
{% endif %}
{% set options = ['First option', 'Second option'] %}
{% for option in options %}
{{ option }}
{% endfor %}
{% if airtable is defined %}
{{ errorList(airtable.getErrors('Single-sele{ct')) }}
{% endif %}
{% set options = ['First option', 'Second option'] %}
{% for option in options %}
{{ option }}
{% endfor %}
{% if airtable is defined %}
{{ errorList(airtable.getErrors('Multi-select')) }}
{% endif %}
Date
{% if airtable is defined %}
{{ errorList(airtable.getErrors('Date')) }}
{% endif %}
Accept terms
{% if airtable is defined %}
{{ errorList(airtable.getErrors('Checkbox')) }}
{% endif %}
```
_Find records in table_
```twig
{% set records = craft.airtable.findRecords() %}
{% if records | length %}
Name
E-mail
Date
{% for record in records %}
{% set fields = record.getFields() %}
{{ fields['Name']|default('') }}
{{ fields['E-mail']|default('') }}
{{ fields['Date']|default('') }}
{% endfor %}
{% endif %}
```
_Find records in table with criteria_
```twig
{% set records = craft.airtable.findRecords({
'Name': 'Thomas'
}) %}
{% if records | length %}
Name
E-mail
Date
{% for record in records %}
{% set fields = record.getFields() %}
{{ fields['Name']|default('') }}
{{ fields['E-mail']|default('') }}
{{ fields['Date']|default('') }}
{% endfor %}
{% endif %}
```
## Airtable Roadmap
Some things to do, and ideas for potential features:
* Support multiple tables
* Support attachments
* Add logging
Brought to you by [Superbig](https://superbig.co)