double_field.rules.inc in Double Field 7.2
Rules integration for the double field module.
File
double_field.rules.inc
View source
<?php
function double_field_rules_data_info() {
return array(
'double_field' => array(
'label' => t('Double field'),
'wrap' => TRUE,
'property info' => double_field_rules_property_info(),
'ui class' => 'DoubleFiledDataUIDoubleField',
),
);
}
function double_field_rules_property_info() {
return array(
'first' => array(
'type' => 'text',
'label' => t('First subfield'),
'setter callback' => 'entity_property_verbatim_set',
),
'second' => array(
'type' => 'text',
'label' => t('Second subfield'),
'setter callback' => 'entity_property_verbatim_set',
),
);
}
class DoubleFiledDataUIDoubleField extends RulesDataUI implements RulesDataDirectInputFormInterface {
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
foreach (double_field_rules_property_info() as $subfield => $info) {
$form[$name][$subfield] = array(
'#type' => 'textarea',
'#title' => $info['label'],
'#default_value' => $settings['value'][$subfield],
);
}
return $form;
}
public static function render($value) {
return array(
'content' => array(
'#markup' => is_array($value) ? implode(' & ', $value) : $value,
),
);
}
}