public static function Notifications_Field::build_from_value in Notifications 7
Build a field object from submitted values
1 call to Notifications_Field::build_from_value()
- Notifications_Subscription::build_fields_from_submission in ./
notifications.subscription.inc - Build submitted fields (match them with this subscription type fields)
File
- ./
notifications.field.inc, line 222 - Drupal Notifications Framework - Default class file
Class
- Notifications_Field
- Base class for Notifications fields
Code
public static function build_from_value($data, $type = NULL, $index = NULL) {
if (is_object($data)) {
if (!$type || $data->type == $type) {
$field = $data;
}
}
elseif (is_array($data)) {
if (isset($data['type']) && (!$type || $type == $data['type'])) {
$field = self::build_type($data['type']);
if (isset($data['value'])) {
$value = $field
->parse_value($data['value']);
$field
->set_value($value, TRUE);
// Set value with previous validation
}
}
}
elseif ($type) {
$field = self::build_type($type);
$value = $field
->parse_value($data);
$field
->set_value($value, TRUE);
// Set value with previous validation
}
if (!empty($field)) {
$field->position = $index;
return $field;
}
}