Multiple Files at once?

edited February 2014 in Modules
Hi again admin,

So i have:

$fields['images'] = array('type' => 'file', 'overwrite' => FALSE, 'display_overwrite' => FALSE, 'multiple' => TRUE);

Which does work as expected allowing me to upload multiple files one by one. However how can I have it so when I click "choose file" I am able to select multiple files at once? Is this possible?

Comments

  • edited February 2014
    According to google, with the latest browsers this should be possible with having

    input type="file[]" multiple

    However looking at what fuelCMS generates for multiple files, (an input for each) I'm thinking this might not work.

    So I'll add a second question:

    How can I have a custom input within function form_fields() in a simple module?

    <?php
    function form_fields($values = array(), $related_fields = array())
    {
    $fields = parent::form_fields($values, $related_fields);
    $CI =& get_instance();

    $user_id = NULL;
    if (!empty($values['id']))
    {
    $id = $values['id'];
    }
    $this->form_builder->load_custom_fields(APPPATH.'config/custom_fields.php');
    $fields['content'] = array('type' => 'wysiwyg', 'editor' => 'wysiwyg');
    $fields['images'] = array('type' => 'file', 'overwrite' => FALSE, 'display_overwrite' => FALSE, 'multiple' => TRUE);
    //Custom HTML here somehow?
    return $fields;
    }
    ?>

    Will i need to change to an advanced module?
  • edited 8:12AM
    You can create a custom field type that can be recognized by Form_builder to serve up what you need. The Fuel_custom_fields.php class contains a bunch that FUEL uses as an example. This coupled with the fuel/modules/fuel/config/custom_fields.php configuration file to make the proper associations with the custom field type.

    So in general, you can create your own class or function, that returns an HTML string and store it in your fuel/application/libraries/ folder. Any additional javascript or CSS can be added to your assets directory and then mapped accordingly in your fuel/application/config/custom_fields.php file which is used for you application specific custom fields.

    A little more can be read in the documentation here:
    http://docs.getfuelcms.com/general/forms#association_parameters
Sign In or Register to comment.