本文整理汇总了PHP中opToolkit::getCultureChoices方法的典型用法代码示例。如果您正苦于以下问题:PHP opToolkit::getCultureChoices方法的具体用法?PHP opToolkit::getCultureChoices怎么用?PHP opToolkit::getCultureChoices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opToolkit
的用法示例。
在下文中一共展示了opToolkit::getCultureChoices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
public function configure()
{
$this->user = sfContext::getInstance()->getUser();
$languages = sfConfig::get('op_supported_languages');
$opt_languages = $this->getOption('languages', array());
$languages = array_unique(array_merge($languages, $opt_languages));
$choices = opToolkit::getCultureChoices($languages);
$this->setDefaults(array('culture' => $this->user->getCulture()));
$this->setWidgets(array('culture' => new sfWidgetFormChoice(array('choices' => $choices)), 'next_uri' => new opWidgetFormInputHiddenNextUri()));
$this->setValidators(array('culture' => new sfValidatorChoice(array('choices' => array_keys($choices))), 'next_uri' => new opValidatorNextUri()));
$this->widgetSchema->setLabels(array('culture' => 'Languages'));
$this->widgetSchema->setNameFormat('language[%s]');
}
示例2: generateWidget
public static function generateWidget($field, $choices = array())
{
$field = self::arrayKeyCamelize($field);
$params = self::generateWidgetParams($field, $choices);
if (in_array($field['FormType'], self::$choicesType)) {
if ($field['FormType'] === 'select') {
if (!$field['IsRequired']) {
$params['choices'] = array('' => sfContext::getInstance()->getI18N()->__('Please Select')) + $params['choices'];
}
} else {
$params['expanded'] = true;
}
}
switch ($field['FormType']) {
case 'checkbox':
$params['multiple'] = true;
$obj = new sfWidgetFormChoice($params);
break;
case 'select':
$obj = new sfWidgetFormChoice($params);
break;
case 'radio':
$obj = new sfWidgetFormChoice($params);
break;
case 'textarea':
$obj = new sfWidgetFormTextarea($params);
break;
case 'rich_textarea':
$obj = new opWidgetFormRichTextarea($params);
break;
case 'password':
$obj = new sfWidgetFormInputPassword($params);
break;
case 'date':
unset($params['choices']);
$params['culture'] = sfContext::getInstance()->getUser()->getCulture();
$params['month_format'] = 'number';
if (!$field['IsRequired']) {
$params['can_be_empty'] = true;
}
$obj = new opWidgetFormDate($params);
break;
case 'increased_input':
$obj = new opWidgetFormInputIncreased($params);
break;
case 'language_select':
$languages = sfConfig::get('op_supported_languages');
$choices = opToolkit::getCultureChoices($languages);
$obj = new sfWidgetFormChoice(array('choices' => $choices));
break;
case 'country_select':
$info = sfCultureInfo::getInstance(sfContext::getInstance()->getUser()->getCulture());
$obj = new sfWidgetFormChoice(array('choices' => $info->getCountries()));
break;
case 'region_select':
$list = sfYaml::load(sfConfig::get('sf_lib_dir') . '/config/config/regions.yml');
$type = $field['ValueType'];
if ('string' !== $type && isset($list[$type])) {
$list = $list[$type];
$list = array_combine($list, $list);
} else {
foreach ($list as $k => $v) {
if ($v) {
$list[$k] = array_combine($v, $v);
}
}
}
$list = opToolkit::arrayMapRecursive(array(sfContext::getInstance()->getI18N(), '__'), $list);
$obj = new sfWidgetFormChoice(array('choices' => $list));
break;
default:
$obj = new sfWidgetFormInput($params);
}
return $obj;
}