We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50135
    • 1 Posts
    Hi,

    I'm using the Formz plugin. So far I've added the plugin to the site so that the forms can be added and changed at multiple places in the site. Now however I need to add the capability, when a user is logged in, to save a part completed form and reload the form later with the fields filled in. So far I have adapted the formz standard chunk to add a prehook which I need to fill the fields with values from the database, currently I can't get the prehook to fill the fields at all even when I have a static field (ie. not one created using the formz plugin). Can anyone see what I'm doing wrong?

    This is the snippet call in the template:

    [[!fmzForms? &id=`[[*Form]]` &tpl=`saveFormTpl`]]


    This is the "saveFormTpl" chunk:

    [[!FormIt?
    	&preHooks=`loadSavedValues`
    	&hooks=`[[+action]][[+hooks:notempty=`,[[+hooks]]`]]`
    	&excludeFields=`submit[[+id]]`
        &submitVar=`submit[[+id]],save[[+id]]`
    	&formid=`[[+id]]` [[- "Form ID"]]
    	&store=`1`
    	&storeTime=`900`
    	
    	&successMessage=`<p>[[+success_message]]</p>`
    	&emailTo=`[[+email:default=``]]`
        [[+properties]]
    	[[+validation:notempty=`&validate=`[[+validation]]``]]
    	[[+validationText:notempty=`[[+validationText]]`]]
    ]]
    
    
    
    [[!+fi.successMessage]]
    [[!+fi.validation_error_message]]
    
    <form class="form [[+identifier]]" action="" method="post">
    	<fieldset>
    	 <input type="text" name="thisemail" id="thisemail" value="" >
    		[[!+fields]]
    	</fieldset>
    
    	<div class="actions">
    	<input type="submit" name="save[[+id]]" value="Save" class="btn primary" />
    		<input type="submit" name="submit[[+id]]" value="[[+action_button:default=`Submit`]]" class="btn primary" />
    	</div>
    </form>
    
    



    And this is the "loadSavedValues" snippet which isn't loading a value into either of the fields:

    <?php
    $hook->setValue('thisemail','[email protected]');
    $hook->setValue('[[+field15]]','[email protected]');
    return true;


    If I'm going about this the wrong wayhas anyone have any advice on how I can use the formz plugin to set the values if they have been saved in the database and then save them to again?

    Thank you [ed. note: fernsco last edited this post 11 years, 6 months ago.]