protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $culture = sfContext::getInstance()->getUser()->getCulture(); $this->addOption('culture', $culture); $this->addOption('languages'); $languages = sfCultureInfo::getInstance($culture)->getLanguages(isset($options['languages']) ? $options['languages'] : null); $cultures = sfCultureInfo::getInstance($culture)->getCultures(); $countries = sfCultureInfo::getInstance($culture)->getCountries(); $values = array(); foreach ($cultures as $key => $culture_info) { if (strlen($culture_info) == 5) { $culture_small = substr($culture_info, 0, 2); $countrie_small = substr($culture_info, 3, 2); if (array_key_exists($culture_small, $languages) && array_key_exists($countrie_small, $countries)) { $select_language = preg_replace('/^[' . $culture_small . ']{2}/i', $languages[$culture_small], $culture_info); $select = preg_replace('/[' . $countrie_small . ']{2}$/i', '(' . $countries[$countrie_small] . ')', $select_language); $values[$culture_info] = ucfirst(str_replace('_', ' ', $select)); } } } if (count($values) == 0) { $values[''] = 'No languages found'; } asort($values); $this->setOption('choices', $values); }
protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->addRequiredOption('text', 'EnllaƧ'); $this->addRequiredOption('url', '#'); $this->addRequiredOption('id', ''); }
/** * Configures the widget. * * Available options: * * * value_widget: The widget that holds the searched value * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetForm */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->addOption('default_text', false); $this->addOption('no_results_text', null); $this->addOption('allow_single_deselect', false); }
/** * Constructor. * * Available options: * * * edit_mode: A Boolean: true to enabled edit mode, false otherwise * * with_delete: Whether to add a delete checkbox or not * * delete_label: The delete label used by the template * * template: The HTML template to use to render this widget when in edit mode * The available placeholders are: * * %input% (the image upload widget) * * %delete% (the delete checkbox) * * %delete_label% (the delete label text) * * In edit mode, this widget renders an additional widget named after the * file upload widget with a "_delete" suffix. So, when creating a form, * don't forget to add a validator for this additional field. * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormSelect */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->addOption('edit_mode', true); $this->addOption('with_delete', true); $this->addOption('delete_label', 'remove this'); $this->addOption('template', '%input%<br />%delete% %delete_label%'); }
/** * Constructor. * * Available options: * * * model: The model class (required) * * add_empty: Whether to add a first empty value or not (false by default) * If the option is not a Boolean, the value will be used as the text value * * method: The method to use to display object values (__toString by default) * * order_by: An array composed of two fields: * * The column to order by the results (must be in the PhpName format) * * asc or desc * * criteria: A criteria to use when retrieving objects * * connection: The Doctrine connection to use (null by default) * * multiple: true if the select tag must allow multiple selections * * @see sfWidgetFormSelect */ protected function configure($options = array(), $attributes = array()) { $this->addRequiredOption('model'); $this->addOption('add_empty', false); $this->addOption('method', '__toString'); $this->addOption('order_by', null); $this->addOption('criteria', null); $this->addOption('connection', null); $this->addOption('multiple', false); parent::configure($options, $attributes); }
/** * * Available options: * * * choices: An array of possible choices (required). Pass 2D array in * the following format to get group headings: * <pre> * array('Sri Lanka' => array('KDY'=>'Kandy', 'CBO'=>'Colombo', 'MT'=>'Matara'), * 'Japan' => array('TK'=>'Tokyo', 'YK'=>'Yokohama'), * 'MO' => 'Moskow') * </pre> * * show_all_option: Add an All option * * all_option_label: Label for All option. Defaults to "All" * * show_select_option: Add a -- Select -- option * * select_option_label: Label for Select option. Defaults to "-- Select --" * * select_option_value: Value for Select option. Defaults to -1. * * indent: Should sub items be indented (true) * * indent_string: String to use for indentation (defaults to ) * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormChoiceBase */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->addOption('show_all_option', true); $this->addOption('all_option_label', __('All')); $this->addOption('show_select_option', false); $this->addOption('select_option_label', '-- ' . __('Select') . ' --'); $this->addOption('select_option_value', -1); $this->addOption('indent', true); $this->addOption('indent_string', " "); }
protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); // // option value for 'all' checkbox. Set to a valid option to enable the 'All' option // $this->addOption('show_all_option', true); $this->addOption('all_option_label', __('All')); $this->addOption('show_root', false); $this->addOption('indent', true); $this->addOption('indent_string', " "); // Parent requires the 'choices' option. $this->addOption('choices', array()); }
/** * Constructor. * * Available options: * * * culture: The culture to use for internationalized strings (required) * * currencies: An array of currency codes to use (ISO 639-1) * * add_empty: Whether to add a first empty value or not (false by default) * If the option is not a Boolean, the value will be used as the text value * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormSelect */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->addRequiredOption('culture'); $this->addOption('currencies'); $this->addOption('add_empty', false); // populate choices with all currencies $culture = isset($options['culture']) ? $options['culture'] : 'en'; $currencies = sfCultureInfo::getInstance($culture)->getCurrencies(isset($options['currencies']) ? $options['currencies'] : null); $addEmpty = isset($options['add_empty']) ? $options['add_empty'] : false; if (false !== $addEmpty) { $currencies = array_merge(array('' => true === $addEmpty ? '' : $addEmpty), $currencies); } $this->setOption('choices', $currencies); }
/** * Constructor. * * Available options: * * * culture: The culture to use for internationalized strings (required) * * languages: An array of language codes to use (ISO 639-1) * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormSelect */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->addRequiredOption('culture'); $this->addOption('languages'); // populate choices with all languages $culture = isset($options['culture']) ? $options['culture'] : 'en'; $cultureInfo = new sfCultureInfo($culture); $languages = $cultureInfo->getLanguages(); // restrict languages to a sub-set if (isset($options['languages'])) { if ($problems = array_diff($options['languages'], array_keys($languages))) { throw new InvalidArgumentException(sprintf('The following languages do not exist: %s.', implode(', ', $problems))); } $languages = array_intersect_key($languages, array_flip($options['languages'])); } asort($languages); $this->setOption('choices', $languages); }
/** * Constructor. * * Available options: * * * culture: The culture to use for internationalized strings (required) * * languages: An array of language codes to use (ISO 639-1) * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormSelect */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); // populate choices with all cultures $choices = array(); $cultures = sfCultureInfo::getCultures(sfCultureInfo::SPECIFIC); foreach ($cultures as $culture) { // skip en_US_POSIX if ($culture == "en_US_POSIX") { continue; } try { $choices[$culture] = sfCultureInfo::getInstance($culture)->getEnglishName(); } catch (sfException $e) { } } asort($choices); $this->setOption('choices', $choices); }
/** * Configures the current widget. * * @param array $options An array of options * @param array $attributes An array of default HTML attributes * * @see sfWidgetFormSelect */ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->setOption('multiple', true); }
/** * @see sfWidget */ protected function configure($options = array(), $attributes = array()) { $this->addOption('add_empty', false); $this->addOption('full', true); parent::configure($options, $attributes); }
protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->setOption('multiple', true); $this->setFcbkcompleteOptions(sfConfig::get('app_dmTagPlugin_fcbkcomplete', array())); }