Commit 9b596aea authored by yched's avatar yched

#153101 - provide (hopefully) better explanation on the 'default value - php code' expected format.

parent 0b723029
......@@ -951,16 +951,22 @@ function _content_admin_field($type_name, $field_name) {
$db_info = content_database_info($field);
$columns = array_keys($db_info['columns']);
foreach ($columns as $key => $column) {
$columns[$key] = "'$column' => ...";
$columns[$key] = "'$column' => value for $column";
}
$sample = 'array( 0 => array('. implode(', ', $columns) .'), 1 => ...)';
$sample = 'array(
0 => array('. implode(', ', $columns) .'),
// You\'ll usually want to stop here. Provide more values
// if you want your \'default value\' to be multi-valued :
1 => array('. implode(', ', $columns) .'),
2 => ...
);';
$form['widget']['default_value_fieldset']['advanced_options']['default_value_php'] = array(
'#type' => 'textarea',
'#title' => t('Code'),
'#default_value' => $field['widget']['default_value_php'],
'#rows' => 6,
'#tree' => TRUE,
'#description' => t('Advanced Usage Only: PHP code that returns a default value. Should not include &lt;?php ?&gt; delimiters.<br/>If this field is filled out, the value returned by this code will override any value in the textfield above.<br/>Expected format : @sample.', array('@sample' => $sample)),
'#description' => t('Advanced Usage Only: PHP code that returns a default value. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the value returned by this code will override any value specified above. Expected format :<pre>%sample</pre>Using %link_devel\'s \'devel load\' tab on a %type content page might help you figure out the expected format.', array('%sample' => $sample, '%link_devel' => l('devel.module', 'http://www.drupal.org/project/devel'), '%type' => theme('placeholder', check_plain($type_name)))),
);
}
......@@ -1047,10 +1053,16 @@ function _content_admin_field_validate($form_id, $form_values) {
$db_info = content_database_info($field);
$columns = array_keys($db_info['columns']);
foreach ($columns as $key => $column) {
$columns[$key] = "'$column' => ...";
$columns[$key] = "'$column' => value for $column";
}
$sample = 'array( 0 => array('. implode(', ', $columns) .'), 1 => ...)';
form_set_error('default_value_php', t('The default value php code returned an incorrect value<br/>Expected format : @sample<br/>Returned value : @value', array('@sample' => $sample, '@value' => print_r($return, true))));
$sample = 'array(
0 => array('. implode(', ', $columns) .'),
// You\'ll usually want to stop here. Provide more values
// if you want your \'default value\' to be multi-valued :
1 => array('. implode(', ', $columns) .'),
2 => ...
);';
form_set_error('default_value_php', t('The default value php code returned an incorrect value<br/>Expected format : <pre>%sample</pre>Returned value : %value', array('%sample' => $sample, '%value' => print_r($return, true))));
return;
}
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment