field_validation_php_validator.inc in Field Validation 7.2
File
plugins/validator/field_validation_php_validator.inc
View source
<?php
$plugin = array(
'label' => t('PHP code'),
'description' => t("Be careful, it is powerful and also dangerous."),
'handler' => array(
'class' => 'field_validation_php_validator',
),
);
class field_validation_php_validator extends field_validation_validator {
public function validate() {
return eval($this->rule->settings['data']);
}
function settings_form(&$form, &$form_state) {
$default_settings = $this
->get_default_settings($form, $form_state);
$form['settings']['data'] = array(
'#title' => t('PHP code'),
'#description' => t("Be careful, it is powerful and also dangerous. Do not use <?php ?> at here, for document: http://drupal.org/node/1537028."),
'#type' => 'textarea',
'#default_value' => isset($default_settings['data']) ? $default_settings['data'] : '',
);
parent::settings_form($form, $form_state);
}
}