This topic is locked

Plugin Image Viewer

7/2/2017 3:47:10 AM
PHPRunner General questions
B
bluepoint author

I am trying to build a drag and drop control for the image type control in a plugin. Normally it provides for just a simple file selector.
I have it working just to the point of the Submit. I am having trouble to understand what the submit (getForSubmit) is looking for. I tried the file location and the actual jpeg blob data.
When submitting it does not accept the input and nothing is submitted of the form.
What is this getForSubmit looking for?



Runner.controls.MyPlugin= Runner.extend(Runner.controls.Control, {
.

.

.
getForSubmit: function () {



if (!this.appearOnPage()) {

return [];

}
return ['C:\\Users\\Myuser\\Desktop\\MyImage.jpg']; // the file location
or
return [file.data]; // the actual blob data
// this is the return used in the example; return [this.valueElem.clone().val(this.getValue())];

}

});


As a test I hard coded the selectors to see if the return "cloneArr" look the same in the normal and the plugin. Looks ok, though a lot of stuff in the control. Again, it works up to the point of the submit. Not sure what it is looking for. Any help would be appreciated.



getForSubmit: function() {

/**

* Clone html for iframe submit

* @return {array}

*/

// add real file elem



var radioClone;

var cloneArr = [];



// update

if (selector_mode == 3) {

radioClone = document.createElement('input');

$(radioClone).attr('type', 'hidden');

$(radioClone).attr('id', 'type_ChartImage_1_update');

$(radioClone).attr('name', 'type_ChartImage_1');

$(radioClone).val('file2');

cloneArr.push($(radioClone));

}



//keep

if (selector_mode == 1) {

radioClone = document.createElement('input');

$(radioClone).attr('type', 'hidden');

$(radioClone).attr('id', 'type_ChartImage_1_keep');

$(radioClone).attr('name', 'type_ChartImage_1');

$(radioClone).val('file0');

cloneArr.push($(radioClone));

}



//delete

if (selector_mode == 2) {

radioClone = document.createElement('input');

$(radioClone).attr('type', 'hidden');

$(radioClone).attr('id', 'type_ChartImage_1_delete');

$(radioClone).attr('name', 'type_ChartImage_1');

$(radioClone).val('file1');

cloneArr.push($(radioClone));

}



var realFile = this.valueElem;

var clone = this.valueElem.clone(true);

clone.insertAfter(realFile);

cloneArr.push(realFile);

this.valueElem = clone;

debugger;

return cloneArr;

}
Sergey Kornilov admin 7/3/2017

I recommend you to check SignaturePad plugin that comes with PHPRunner. It shows you how to work with images.
getForSubmit() function is not even required and all job is done in readWebValue() function.

B
bluepoint author 7/5/2017



I recommend you to check SignaturePad plugin that comes with PHPRunner. It shows you how to work with images.
getForSubmit() function is not even required and all job is done in readWebValue() function.


Well I looked at this, but you still need to understand what this getForSubmit function is looking for to feed the form. The inputs to the plugin code is easier as one can go into debug mode and look to what is available.
What I ended up doing is doing independent ajax uploads. A bit of a hack but for what we need it was sufficient.
Then do the following to ignore the field on the save.
getForSubmit: function () { return [] }