Thanks for supplying the answer to why my SAEF using two custom nGen fields in an SAEF was not working. Unfortunately, I am little dense, and after trying to follow these directions, it still doesn’t work.
I haven’t yet gotten to testing to see if this form really works yet, cross that bridge when I come to it. First I need to get all the custom fields to show up on the form, and the nGen fields don’t.
My SAEF just shows the names of the fields in question, i.e. “Main Picture” and “Second Picture.”
The rest of the fields show up correctly as defined in the custom fields group definitions.
Problem No.1: I don’t know where to add this stuff
<input type="file" name="field_id_7" />
<input type="hidden" name="field_id_7[file_name]" />
<input type="hidden" name="field_id_7[existing]" />
Here’s what I did:
I installed the ext.simple_saef_enctype.php extension and enabled it in the extension manager.
I added an “{if file}” with the the hidden fields into the section of the form where other field types seem to be defined (custom fields)to conform with what I am seeing there…
I changed the name of the “field_id” to 7, which is the number I believe is associated with the “Main Picture” field (I got that from the order rank it is assigned in the custom field group)
The entire SAEF code I am trying to make work looks like this:
<!--BEGIN STAND ALONE ENRTY FORM -->
{exp:weblog:entry_form weblog="tales" return="tales/index" preview="tales/talesPublish" enctype="multi"}
<table width="240" height="671" border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="left" valign="top"><input type="submit" name="submit" value="Submit" />
<input type="submit" name="preview" value="Preview" />
{status_menu}
Status
<select name="status">
{select_options}
</select>
{/status_menu}
Date
<input type="text" name="entry_date" value="{entry_date}" maxlength="23" size="25" /></p>
Expiration Date
<input type="text" name="expiration_date" value="{expiration_date}" maxlength="23" size="25" /></p>
Comment Expiration Date
<input type="text" name="comment_expiration_date" value="{comment_expiration_date}" maxlength="23" size="25" /></p>
<input type="checkbox" name="sticky" value="y" {sticky} /> Make Entry Sticky
<input type="checkbox" name="allow_comments" value="y" {allow_comments} /> Allow Comments
<input type="checkbox" name="allow_trackbacks" value="y" {allow_trackbacks} /> Allow Trackbacks
<input type='checkbox' name='dst_enabled' value='y' {dst_enabled} />DST Active on Date of Entry
{ping_servers}
Ping Servers
{ping_row}
<input type="checkbox" name="ping[]" value="{ping_value}" {ping_checked} /> {ping_server_name}
{/ping_row}
{/ping_servers} </td>
</tr>
</table>
</div>
<!-- end #sidebar2 -->
<!-- begin #mainContent -->
<div id="mainContent">
{preview}
<h1>{title}</h1>
{display_custom_fields}
{/preview}
Title
<input type="text" name="title" id="title" value="{title}" size="50" maxlength="100"></p>
URL Title
<input type="text" name="url_title" id='url_title' value="{url_title}" maxlength="75" size="50" /></p>
{custom_fields}
{if required}* {/if}{field_label}
{field_instructions}
{if textarea}
<textarea id="{field_name}" name="{field_name}" dir="{text_direction}" cols="50" rows="{rows}">{field_data}</textarea><br >
{/if}
{if textinput}
<input type="text" dir="{text_direction}" id="{field_name}" name="{field_name}" value="{field_data}" maxlength="{maxlength}" size="30"><br >
{/if}
{if pulldown}
<select id="{field_name}" name="{field_name}">
{options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
</select>
{/if}
{if date}
<input type="text" id="{field_name}" name="{field_name}" value="{field_data}" maxlength="{maxlength}" size="50"><br >
{/if}
{if relationship}
<select id="{field_name}" name="{field_name}">
{options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
</select>
{/if}
{if file}
<input type="file" name="field_id_7" />
<input type="hidden" name="field_id_7[file_name]" />
<input type="hidden" name="field_id_7[existing]" />
{/if}
{/custom_fields}
Trackback URLs
<textarea name="trackback_urls" cols="50" rows="5">{trackback_urls}</textarea>
</div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" >
{/exp:weblog:entry_form}
Problem No.1: I don’t know where to add this stuffHere’s what I did: I installed the ext.simple_saef_enctype.php extension and enabled it in the extension manager. I added an “{if file}” with the the hidden fields into the section of the form where other field types seem to be defined (custom fields)to conform with what I am seeing there… I changed the name of the “field_id” to 7, which is the number I believe is associated with the “Main Picture” field (I got that from the order rank it is assigned in the custom field group)<input type="file" name="field_id_7" /> <input type="hidden" name="field_id_7[file_name]" /> <input type="hidden" name="field_id_7[existing]" />
The ordering of fields is different from the actual field IDS; return to the Custom Fields table in your CP, and instead of looking at the rank number, click to edit the “Main Picture” custom field. Once on the edit streen, look at the entire URL; toward the end it will have something like “…&field_id=XX” - THAT is your field ID.
I haven’t looked at the rest of your code, but see where that gets you…
Stepping back a minute…
I don’t know if “file” is a known custom field type, so I don’t know if anything in your {if file}…{/if} will ever spit out anything. Just a thought.
Have you read Brandon Kelly’s documentation on how to use FieldFrame types with SAEFs? It’s actually quite simple:
http://brandon-kelly.com/fieldframe/docs/saef
If you follow his instructions, you’ll actually get the entire nGen File field interface. The “Simple SAEF Enctype” extension I made was only useful (to me) because I didn’t want to expose that much to the end-user; I only wanted the most basic file upload form field, and wasn’t using SAEF as an edit form, etc etc.
Thanks John! Making progress…
I got from your post that I should remove the “if” stuff, and I did, and now I have not just field 7 (main picture) but also field 8 (second picture) AND an extra third browser button.
I only added:
<input type="file" name="field_id_7" />
<input type="hidden" name="field_id_7[file_name]" />
<input type="hidden" name="field_id_7[existing]" />
… and yet, extra things are showing up, one of which is not part of the custom form group at all (the third browser/upload button)
?
thanks… 😊
arghhh… Now I have the form showing the two upload browser buttons, but when I try to post an entry from either the SAEF or the Publish form within the CP, I get this:
Fatal error: Out of memory (allocated 32768000) (tried to allocate 15488 bytes) in /homepages/15/d127239825/htdocs/golfoDulceNews/mother/extensions/fieldtypes/ngen_file_field/ft.ngen_file_field.php on line 842
I can’t now edit any entries, I get the same message.
I got it working again once by deleting the uploaded images (which weighed in one iteration 260kb and 120 Kb respectively) manually from the server. This did not work the second time, I am still trying to repair the damage, whatever it is.
Looking directly at line 842 in the ft.ngen_file_field.php fileshows me this:
$im = imagecreatefromjpeg($file);
… not particularly obvious to me what to do…
:-(
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.