Fieldtype Select Options
Aus Wikizone
ProcessWire Fieldtype 'Select Options' (Core)
Lässt eine Wahl von einem oder mehrerer Optionen als Selectbox, Checkboxen oder Radio Buttons zu.
Links
Definition im Backend
Snippets
Available Options
// Available Options
// If you are going to be using the selections for anything,
// use the $option->id property, rather than the title
$field = $fields->get('categories');
$options = $field->type->getOptions($field);
User Language
$options = $fieldtypes->get('FieldtypeOptions')->getOptions($fields->get('YOURFIELDNAME'));
foreach ($options as $value) {
echo $value->$title;
echo $value->$label;
echo $value->$description;
}
This outputs title, label and description in the user language.
All Languages
//get value and title in different languages;
if ($user->language->name != 'default') {
$title = "title{$user->language}";
$value = "value{$user->language}";
} else {
$title = 'title';
$value = 'value';
}
$options = $fieldtypes->get('FieldtypeOptions')->getOptions('YOURFIELDNAME');
foreach($options as $option) {
echo $option->id;
echo $option->$value;
echo $option->$title;
};