ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Set file input value with url segment variable

July 03, 2014 10:35pm

Subscribe [1]
  • #1 / Jul 03, 2014 10:35pm

    skalex

    1 posts

    Hey everyone,
    I’ve created some sites with ee , but never went too further.
    This time, i’m trying to pre-set a form input value (actually, a File Field) with an existing file_id (previously selected) coming from the last url segment variable.

    like this: index.php/myForm/15

    Did try filling the value attribute with last_segment, but it keeps saying “The my_file_field field is required.”

    {if segment_3 == ''}
       {field:my_file_field}    
    {if:else}
       <input type="file" name="my_file_field"  data_directory="2" value="{segment_3}" /></p>
    {/if}

    I guess this is not working because of the file input component, implemented differently by each browser.

    So, how should I change my form in order to set my_file_field to a file_id reference for an existing file?

    The ‘Show existing files’ option looks good but I need to filter the list. I can do some coding but don’t know where to look in ee.

    Thanks in advance

  • #2 / Jul 04, 2014 8:50am

    skalex

    1 posts

    Ok, after a few hours, it was fairly simple

    the input I was looking for is named “my_file_field_existing

    and for the record, the file file input named my_file_field should also be in the form.

    That’s it.

    Thanks anyway..

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases