GithubHelp home page GithubHelp logo

timkelty / craft3-fields Goto Github PK

View Code? Open in Web Editor NEW

This project forked from newism/craft3-fields

0.0 2.0 0.0 7.2 MB

Address, telephone, email, embed and gender fields for CraftCMS 3.x

License: Other

PHP 79.08% HTML 20.92%

craft3-fields's Introduction

Attention: This plugin is under active development and will change. This is a preview release.

Address, telephone and email fields for CraftCMS 3.x

Address

Address field powered by Google's dataset (commerceguys/addressing).

Features:

  • Auto-complete powered by Google Place API
  • Address form formatting based on country powered by commerceguys/addressing
  • Validation / Geo-coding on submission (TODO)

Template Tags:

The normalizeValue method always returns an AddressModel. All public properties are available:

Given entry.address is your field…

See: https://github.com/commerceguys/addressing/blob/master/src/AddressInterface.php
{{ entry.address.countryCode }}
{{ entry.address.administrativeArea }}
{{ entry.address.locality }}
{{ entry.address.dependentLocality }}
{{ entry.address.postalCode }}
{{ entry.address.sortingCode }}
{{ entry.address.addressLine1 }}
{{ entry.address.addressLine2 }}
{{ entry.address.organization }}
{{ entry.address.recipient }}
{{ entry.address.locale }}

See: https://github.com/commerceguys/addressing/blob/master/src/Country/Country.php
{{ entry.address.country.countryCode }}
{{ entry.address.country.name }}
{{ entry.address.country.threeLetterCode }}
{{ entry.address.country.numericCode }}
{{ entry.address.country.currencyCode }}
{{ entry.address.country.locale }}

{{ entry.address.placeData }}
{{ entry.address.latitude }}
{{ entry.address.longitude }}
{{ entry.address.mapUrl }}

Address Demo

Telephone

Telephone field powered by Googles phone number library implemented via giggsey/libphonenumber-for-php

Features:

  • Validate phone number based on country code
  • Format phone number as E164, international, national or RFC3966
  • Stores Telephone model and raw user input

Template Tags:

Given entry.telephone is your field…

{{ entry.telephone }} outputs the phone number in international format.

You can also choose a specific format:

{{ entry.telephone.format('E164') }}
{{ entry.telephone.format('international') }}
{{ entry.telephone.format('national }}
{{ entry.telephone.format('RFC3966') }}

The raw input from the user is also available:

{{ entry.telephone.rawInput }}

Telephone Demo

Email

Features:

  • Email validation using Yii validation

Email Demo

Embed

Features:

  • Embed social media posts / media directly from a URL
  • Live preview

Template Tags:

Given entry.embedField is your field…

  • {{ entry.embedField.embedData }} outputs the returned embed object.
  • {{ entry.embedField.embedData.code | raw }} outputs the returned embed javascript code.

Embed Demo

Person Name

Person name field with:

  • Honorific Prefix
  • Given Names
  • Additional Names
  • Family Names
  • Honorific Suffix

Person Name Demo

Gender

Non-binary gender field with:

  • Sex
  • Identity

Gender

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require newism/craft3-fields

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Install

Install plugin in the Craft Control Panel under Settings > Plugins.

Configuration

The plugin comes with a config.php file that defines some sensible defaults.

Copy src/config.php to CRAFT_CONFIG_PATH and rename the file to nsm-fields.php.

Road Map

Some things to do, and ideas for potential features:

  • Split out each field into it's own plugin. Keep this plugin as a single composer file which pulls all felds in
  • Address validation / Geo-coding on submission
  • Display address as text in field with option to "Edit" to reduce size of field in UI
  • Update commerceguys/addressing when next stable version is released

1.0

  • Release it

1.1

  • Add "NSM Publish Hints" field

1.2

  • Add video field with yoututbe, vimeo previews See Embed Field

Credits

Brought to you by Newism

craft3-fields's People

Contributors

leevigraham avatar makeilalundy avatar brandonkelly avatar domstubbs avatar markhuot avatar webrgp avatar rosanarufer avatar swey avatar

Watchers

Tim Kelty avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.