function features_export_form_validate_field in Features 6
Same name and namespace in other branches
- 7.2 features.admin.inc \features_export_form_validate_field()
- 7 features.admin.inc \features_export_form_validate_field()
Validation for project field.
1 string reference to 'features_export_form_validate_field'
- features_export_form in ./
features.admin.inc - Form callback for features export form. Acts as a router based on the form_state.
File
- ./
features.admin.inc, line 153
Code
function features_export_form_validate_field($element, &$form_state) {
switch ($element['#name']) {
case 'module_name':
if (!preg_match('!^[a-z0-9_]+$!', $element['#value'])) {
form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
else {
if (empty($element['#default_value']) && features_get_info('module', $element['#value'])) {
form_error($element, t('A module by the name @name already exists on your site. Please choose a different name.', array(
'@name' => $element['#value'],
)));
}
}
break;
case 'project_status_url':
if (!empty($element['#value']) && !valid_url($element['#value'])) {
form_error($element, t('The URL %url is invalid. Please enter a fully-qualified URL, such as http://www.example.com/feed.xml.', array(
'%url' => $element['#value'],
)));
}
break;
case 'version':
preg_match('/^(?P<core>\\d+\\.x)-(?P<major>\\d+)\\.(?P<patch>\\d+)-?(?P<extra>\\w+)?$/', $element['#value'], $matches);
if (!empty($element['#value']) && !isset($matches['core'], $matches['major'])) {
form_error($element, t('Please enter a valid version with core and major version number. Example: !example', array(
'!example' => '6.x-1.0',
)));
}
break;
}
}