function _flash_form_after_build in Flash Node 5
Various functions to manipulate the form after building in case default values are being reset. It also changes the description on the flash file field when a file has been uploaded, to help the user to identify which file is in use on this node. #parents is used as the identified in case the title is being translated. Not sure if this is the right way to achieve this, but it appears to work!
1 string reference to '_flash_form_after_build'
- flash_form in ./
flash.module - Implementation of hook_form
File
- ./
flash.module, line 367
Code
function _flash_form_after_build($form, $form_values) {
// Change file upload description to reflect current upload if there is one
if (!empty($form_values['flash']['_flash']) && $form['#parents'][0] == 'flashfile') {
$form['#description'] = t('Current file is %filename. Click "Browse..." to upload a different file.', array(
'%filename' => basename($form_values['flash']['_flash']),
));
}
// If width field is empty then reset it to the default width
if (empty($form_values['flash']['width']) && $form['#parents'][1] == 'width') {
$form['#value'] = $form_values['flash']['_width'];
form_set_value($form, $form_values['flash']['_width']);
}
// If height field is empty then reset it to the default height
if (empty($form_values['flash']['height']) && $form['#parents'][1] == 'height') {
$form['#value'] = $form_values['flash']['_height'];
form_set_value($form, $form_values['flash']['_height']);
}
// If version field is empty then reset it to the default height
if (empty($form_values['flash']['version']) && $form['#parents'][1] == 'version') {
$form['#value'] = variable_get('flash_version', 6);
form_set_value($form, variable_get('flash_version', 6));
}
// If version field is empty then reset it to the default height
if (empty($form_values['flash']['build']) && $form['#parents'][1] == 'build') {
$form['#value'] = variable_get('flash_build', 0);
form_set_value($form, variable_get('flash_build', 0));
}
// Return the amended form element
return $form;
}