i have a problem with formit hook values not being set by a prehook/snippet. Basically it's an edit form that needs to catch the values and populate the form fields. This is basically a copy of several other add/edit forms in the same site that do work ...
First off - here is the form:
<p> Please upload a maximum of 6 Mp3s.<p><br/>
[[!FormIt?
&preHooks=`GetArtistData`
&queryData=`GetOneMp3`
&clearFieldsOnSuccess=`1`
&submitVar=`edit_mp3`
]]
[[!FormIt?
&hooks=`UpdateArtist`
&successMessage=`MP3[s] deleted.`
&clearFieldsOnSuccess=`1`
&queryData=`deletemp3`
&submitVar=`delete_mp3s`
]]
[[!FormIt?
&hooks=`UpdateArtist,GetTrimmed`
&successMessage=`A new MP3 has been added!`
&clearFieldsOnSuccess=`1`
&queryData=`files`
&validate=`label:required,audio:required`
&submitVar=`submit_new_mp3`
]]
<div class="profilenav">
[[$ShowProfileNav]]
</div>
<div class="profileright">
[[+fi.successMessage:notempty=`<div class="success">[[+fi.successMessage]]</div>`]]
[[+fi.errorMessage:notempty=`<div class="error">[[+fi.errorMessage]]</div>`]]
<!-- [!$AddAudioForm] -->
<div class="profileview">
<form class="default profile" action="[[~[[*id]]]]" method="post" enctype="multipart/form-data">
<input type="hidden" name="mp3" value="mp3" />
<input type="hidden" name="mp3id" value="[[!+fi.mp3id]]" />
<ul >
<li>
<label for="label">Add a new MP3 </label>
</li>
<li>[[!+fi.error.label]]
<label for="label">MP3 Title<span class="required"> *</span></label>
<input type="text" name="label" id="label" value="[[!+fi.label]]" />
</li>
<li>[[!+fi.error.company]]
<label for="company">Label</label>
<input type="text" name="company" id="company" value="[[!+fi.company]]" />
</li>
<li>[[!+fi.error.audio]]
<label for="title">MP3<span class="required"> *</span></label>
<input name="audio" type="file">
</li>
<li>
<label> </label>
<button type="submit" name="submit_new_mp3" class="resetpass" value="submit_new_mp3"><span>Add MP3</span></button>
</li>
<li class="required">
<label> </label>
Fields marked <span class="required"> *</span> are required
</li>
</ul>
</form>
<p> </p>
<form class="default profile" action="[[~[[*id]]]]" method="post" enctype="multipart/form-data" name="mp3-edit-delete">
<ul class="mp3">
[[!GetArtistData? &queryData=`audio`]]
<!-- this just gets all the mp3s and loops them into a chunk example below -->
<li>
<label class="title">[[+label]] [[+company]]</label>
<object type="application/x-shockwave-flash" data="/assets/dewplayer/dewplayer.swf" width="200" height="20" id="dewplayer" name="dewplayer" class="mp3">
<param name="wmode" value="transparent">
<param name="movie" value="/assets/dewplayer/dewplayer.swf">
<param name="flashvars" value="mp3=[[+location]]&autostart=0&autoreplay=0&showtime=1">
</object>
<button type="submit" name="delete_mp3s" class="resetpass" value="delete_[[+id]]"><span>Delete</span></button>
<button type="submit" name="edit_mp3" class="resetpass" value="[[+id]]" style="margin-left:10px;"><span>Edit</span></button>
</li>
<!-- end chunk -->
</ul>
</form>
</div>
</div>
The very first formit call is what we are looking at, it does execute the GetArtistData snippet:
<?php
$classfile = dirname($modx->getOption('core_path')).'/core/components/extdata/controllers/extdata.class.php';
if (file_exists($classfile)) {
$output = include_once $classfile;
} else {
$modx->setLogTarget('ECHO');
$modx->log(modX::LOG_LEVEL_ERROR,'class not found at: '.$file);
}
$scriptproperties['queryData'] = (isset($queryData)) ? $queryData : "";
$scriptproperties['gigid'] = (isset($_POST['edit_gig'])) ? $_POST['edit_gig'] : "";
$scriptproperties['mp3id'] = (isset($_POST['edit_mp3'])) ? $_POST['edit_mp3'] : "";
$scriptproperties['discid'] = (isset($_GET['discid'])) ? $_GET['discid'] : "";
$scriptproperties['placeHolder'] = (isset($placeHolder)) ? $placeHolder : "";
if(class_exists('ExtraData') != true) {
$ExtraData = new ExtData($modx,$scriptproperties);
}
/*
echo '<pre>';
print_r($scriptproperties);
echo '</pre>';
exit();
*/
$output = $ExtraData->getData($scriptproperties,$hook);
return $output;
which does in turn execute the getData function and executes the code in the 'GetOneMp3' switch/case:
case 'GetOneMp3' :
$hook->setValue('errorMessage','this is the error message');
if($scriptproperties['mp3id']){
$mp3id = $scriptproperties['mp3id'];
$mp3Attribs = $artistAttribs->getOne('ArtistAudio', $mp3id);
$hook->setValues(array(
'mp3id'=>$mp3id,
'label'=>$mp3Attribs->get('label'),
'location'=>$mp3Attribs->get('location'),
'bytes'=>$mp3Attribs->get('bytes'),
'company'=>$mp3Attribs->get('company')
));
}
break;
Which does retrieve correct data, it just does not set the form fields!
So like I said, it is a direct copy of several other forms doing exactly this & working, also all the other formit calls work [and return arrors/success messages] I can add and delete mp3s with this....
It's got to be something simple, right?