Skip to content

Commit

Permalink
Adding default value option to Country field type.
Browse files Browse the repository at this point in the history
Addresses #1815.
  • Loading branch information
adamfairholm committed Oct 20, 2012
1 parent 84e59de commit 194301b
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 20 deletions.
Expand Up @@ -4,20 +4,20 @@
* PyroStreams Country Field Type
*
* @package PyroCMS\Core\Modules\Streams Core\Field Types
* @author Parse19
* @copyright Copyright (c) 2011 - 2012, Parse19
* @license http://parse19.com/pyrostreams/docs/license
* @link http://parse19.com/pyrostreams
* @author Adam Fairholm
* @copyright Copyright (c) 2011 - 2012, Adam Fairholm
*/
class Field_country
{
public $field_type_slug = 'country';

public $db_col_type = 'varchar';

public $version = '1.0';
public $version = '1.1';

public $author = array('name'=>'Parse19', 'url'=>'http://parse19.com');
public $custom_parameters = array('default_country');

public $author = array('name' => 'Adam Fairholm', 'url' => 'http://adamfairholm.com');

// --------------------------------------------------------------------------

Expand All @@ -30,7 +30,17 @@ class Field_country
*/
public function form_output($data, $entry_id, $field)
{
return form_dropdown($data['form_slug'], $this->countries($field->is_required), $data['value'], 'id="'.$data['form_slug'].'"');
// Default value
if ( ! $data['value'])
{
$value = (isset($field->field_data['default_country'])) ? $field->field_data['default_country'] : null;
}
else
{
$value = $data['value'];
}

return form_dropdown($data['form_slug'], $this->countries($field->is_required), $value, 'id="'.$data['form_slug'].'"');
}

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -84,6 +94,21 @@ public function pre_output_plugin($input, $params)

// --------------------------------------------------------------------------

/**
* Default Country Parameter
*
* @access public
* @return string
*/
public function param_default_country($input)
{
// Return a drop down of countries
// but we don't require them to give one.
return form_dropdown('default_country', $this->countries('no'), $input);
}

// --------------------------------------------------------------------------

/**
* Countries
*
Expand Down
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "الدولة";
$lang['streams.country.default_country'] = 'Default Country'; #translate
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "Země";
$lang['streams.country.name'] = "Země";
$lang['streams.country.default_country'] = 'Default Country'; #translate
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "Country";
$lang['streams.country.name'] = "Country";
$lang['streams.country.default_country'] = 'Default Country';
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "Pays";
$lang['streams.country.default_country'] = 'Default Country'; #translate
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "Land";
$lang['streams.country.name'] = "Land";
$lang['streams.country.default_country'] = 'Default Country'; #translate
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "Χώρα";
$lang['streams.country.name'] = "Χώρα";
$lang['streams.country.default_country'] = 'Default Country'; #translate
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "Šalis";
$lang['streams.country.name'] = "Šalis";
$lang['streams.country.default_country'] = 'Default Country'; #translate
@@ -1,3 +1,4 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

$lang['streams.country.name'] = "País";
$lang['streams.country.name'] = "País";
$lang['streams.country.default_country'] = 'Default Country'; #translate
@@ -1,6 +1,5 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');


/**
* Swedish translation.
*
Expand All @@ -11,10 +10,5 @@
* @version 1.0.0
*/


$lang['streams.country.name'] = 'Land';



/* End of file country_lang.php */
/* Location: ./system/cms/modules/streams_core/field_types/country/language/swedish */
$lang['streams.country.default_country'] = 'Default Country'; #translate

0 comments on commit 194301b

Please sign in to comment.