Hidden form fields

7 views
Skip to first unread message

Paul Swingewood

unread,
Sep 12, 2022, 6:04:11 AMSep 12
to Joomla! General Development
Hi all,

I have a form which uploads files.
Using the Joomla file upload.

FORM:

                 <input type="hidden" name="jform[uploadedfile_hidden]" id="jform_uploadedfile_hidden" value="<?php echo implode(',', $uploadedfileFiles); ?>" />

Model: (on save)

public function save($data)
    {
        $app = Factory::getApplication();  

    if ($input->exists('uploadedfile_hidden'))
    {
        $v1 = $input->get('uploadedfile_hidden', 0, "INT");
        echo "<p>Int value of p1 is $v1</p>";
        $v1 = $input->get('uploadedfile_hidden', 0, "UINT"); // uint
        echo "<p>Uint value of p1 is $v1</p>";
        $v1 = $input->get('uploadedfile_hidden', 0, "string");
        echo "<p>String Value of p1 is $v1</p>";
    }
    else
    {
        echo "<p>Parameter not specified</p>";
    }
    exit;


No matter what I do the parameter 'uploaded_hidden' isn't there?
What am I doing wrong please?

Why can't I see the parameter 'uploaded_hidden'?


Paul

MarkRS

unread,
Sep 12, 2022, 10:54:09 AMSep 12
to Joomla! General Development
I don't think the "jform" stuff is required, but I don't have time to work out why and what's changed since it was.
I have an import form (importing data from files into the database, which I think is what you're doing.

The html is

<div id="collapseImport">
    <div id="uploadform" class="uploadform">
        <label for="import-file" class="control-label"><?php echo Text::_('COM_MM_IMPORT_FILE'); ?></label>
        <input required type="file" class='form-select' id="import-file" name="Filedata[]" multiple />
        <input class="update-folder" type="hidden" name="folder" id="folder" value="<?php echo $this->state->folder; ?>" />
    </div>
</div>

and then my import method is in the view controller and retrieves the names of files to import simply with

        $files = $this->input->files->get('Filedata', array(), 'array');

And then gets on with it.
Reply all
Reply to author
Forward
0 new messages