定制 atk14/country-field 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

atk14/country-field

Composer 安装命令:

composer require atk14/country-field

包简介

Country select field localized for every single language. It is intended to be used in ATK14 Forms.

README 文档

README

Build Status

Country select field localized for every single language. It is intended to be used in ATK14 Forms.

It uses https://github.com/umpirsky/country-list as the localized countries list.

It also contains Smarty modifier which displays the country name according to its code ISO.

Basic usage

In a form:

<?php
// file: app/forms/users/create_new_form.php
class CreateNewForm extends ApplicationForm {

  function set_up(){
    $this->add_field("name", new CharField([
      "label" => "Your name",
      "hint" => "John Doe"
    ]));

    // other fields...

    $this->add_field("country_code", new CountryField([
      "label" => "Choose your country",
      "initial" => "CZ"
    ]));
  }
}

In a template:

{*
 * file: app/views/users/detail.tpl
 *}

 <h1>{t}Your personal data{/t}</h1>

 <h3>{t}Address{/t}</h3>

 {t}Country:{/t} {$user->getCountryCode()|to_country_name}

Special cases

It's possible to define a limited set of countries.

$this->add_field("country_code", new CountryField([
  "label" => "Choose your favourite V4 country",
  "allowed_countries" => ["CZ","SK","PL","HU"]
]));

It's also possible to define list of countries which are not allowed.

$this->add_field("country_code", new CountryField([
  "label" => "Choose country",
  "disallowed_countries" => ["BZ","IO","CF"]
]));

A title of the empty choice can be set with option empty_choice_text:

	$this->add_field("country_code", new CountryField([
		"empty_choice_text" => "-- select country --"
	]));

The empty choice can be omitted with option include_empty_choice:

	$this->add_field("country_code", new CountryField([
		"include_empty_choice" => false
	]));

Installation

Just use the Composer:

cd path/to/your/atk14/project/
composer require atk14/country-field

ln -s ../../vendor/atk14/country-field/src/app/fields/country_field.php app/fields/country_field.php
ln -s ../../vendor/atk14/country-field/src/app/helpers/modifier.to_country_name.php app/helpers/modifier.to_country_name.php

License

CountryField is free software distributed under the terms of the MIT license

统计信息

  • 总下载量: 24.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固