Back
VFS
VFS
VFS
Forward


Step 7: File Uploads and Virtual File Storage

Adding two more fields to the form:


<?php

lib
/MP3Form.php:

function
MP3_Form(&$vars, $title = '', $edit = true)
{
    
parent::Horde_Form($vars, $title, 'mp3_form');
    
$this->addHidden('', 'id', 'int', false);
    
$this->addVariable(_("Title"), 'song_title', 'text', true);
    
$this->addVariable(_("Artist"), 'song_artist', 'text', true);
    
$this->addVariable(_("Album"), 'song_album', 'text', true);
    
/* Add fields depending on active/inactive rendering. */
    
if ($edit) {
        
$this->addVariable(_("MP3 file"), 'file', 'file', false);
    } else {
        
$this->addVariable(_("MP3 ID tags"), 'song_idtag', 'html', false);
        
$this->addVariable('', 'sound', 'html', false);
    }
}

mp3.php:

$variables->set('song_idtag', Mopple::tagsToHTML($mp3['song_idtag']));
$variables->set('sound', Mopple::playerHTML($id));

$form = &new MP3_Form($variables, $title, false);
$edit_url = Horde::applicationUrl('edit.php');
$edit_url = Util::addParameter($edit_url, array('id' => $mp3['song_id']));
$edit_link = Horde::link($edit_url, sprintf(_("Edit \"%s\""), $title), 'smallheader');
$form->setExtra($edit_link . _("Edit") . '</a>');
$renderer = &$form->getRenderer();

?>