Form that doesn't stick...

my plugin adds a field to the file/upload form. I'd like to check the content of the field before the uploading, and so I'd like to make the form sticky.

This is the code: it works but the form is not sticky, why?

elgg_register_event_handler('action', 'file/upload', 'check_form');
elgg_registerevent_handler('update', 'all', 'myplugin_makesomething');
elgg_registerevent_handler('create', 'all', 'myplugin_makesomething');


...

function check_form() {
  elgg_make_sticky_form("file/upload");
  if (problem_in_the_form) {
    $error = elgg_echo("error!!");
    register_error($error);
    forward(REFERER);
  }
}

  • (forgive typo errors, I can't edit anymore...)

  • I don't believe file fields can be sticky, at least I've never seen one anywhere

  • Yes! it can be made sticky. I have written some codes for it and used it before ... here is just an example of using a Url field and making the Url field form sticky:-

     <?php
    /**
     * Elgg file uploader/edit action
     *
     * @package ElggFile
     */

    // Get variables

    $destination_url = get_input("destination_url");

    //Basic validation

    if(empty($destination_url) ) {
        if(!isset($_FILE['reupload']['name']) ) {
        register_error(elgg_echo('Fill up destination-url'));
        forward(REFERER);
        }    
    }

    // Logoff

    unset($_SESSION['destination_url']);

    // file saved so clear sticky form
    elgg_clear_sticky_form('file');

    // handle results differently for new files and file updates

        forward('file/myplugin_makesomething');

    ?>

     

    Here is an example how the Destination Url Field looks like once it is in action on Upload form:

     

  • @tom:

    prefilling the files is a serious security risk..
    that is why all browsers do not support this.

  • I don't need to prefill the file name field, but I would like to make the category field sticky. I didn't understand in toto Tom's suggestion because I can't know the destination url since it depends on the user who is uploading...

  • @ DhrupDeScoop, for security risk issues, the file fields added to the file e.g "destination_url" and others are checked by a form checker file aganist Wildcards, the Classics, comment syntax, payloads, NewLines, URL Encoded, DataType Conversions, Malformed XML, Xpath Injection variants, Cross-Site Scripting (XSS) and many more before an input/text is processed. I am using the file plugin just as a prototype. An independed plugin that can do all this is in testing stage.

  • hey guys can you help me ,how to add jquery grid in elgg plugin... please guys I already wasted 1 week on it but yet not achieved the grid view.... please help me,,, im going crazyy.. 

  • there are tons of different jquery grid views.........depends on which one you are trying to do, but other than that, this topic is about a sticky form not grid views.  spamming your requests will not endear others to help you.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking