mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 15:57:01 +02:00
Add support for matching data attributes in show-if conditions. Also updated FieldtypeOptions to add data-if-value
attribute to select <option> tags as a way use it. This attribute contains the option value (when separate option values and labels are used). This enables you to match by value rather than by option ID. Example show-if selector: colors.data-if-value=blue
. Previously you could only match by option ID, i.e. colors=123. Maybe we'll add something similar for page refernce fields so that you can match by page name or path, rather than by ID.
This commit is contained in:
@@ -105,7 +105,10 @@ class FieldtypeOptions extends FieldtypeMulti implements Module {
|
||||
if(!$inputfield) $inputfield = $this->wire()->modules->get('InputfieldSelect');
|
||||
|
||||
foreach($this->manager->getOptions($field) as $option) {
|
||||
$inputfield->addOption((int) $option->id, $option->getTitle());
|
||||
$value = $option->value;
|
||||
$attrs = [];
|
||||
if($value) $attrs['data-if-value'] = $value;
|
||||
$inputfield->addOption((int) $option->id, $option->getTitle(), $attrs);
|
||||
}
|
||||
|
||||
if($field->get('initValue')) {
|
||||
|
Reference in New Issue
Block a user