How to prevent printing PDF forms? - livecycle

I have a PDF form and I need to prevent printing this PDF form, if its fields are blank.
To modify my form i user Adobe LiveCycle Designer ES3.
About how can this be done is written here: http://forms.stefcameron.com/2008/04/13/prevent-printing-pdf-forms-in-acrobat-8/
The only thing i need more than in this article - is to suppress message "Printing Cancelled", or overide it with another text.
So, if somebody knows how can it be done, please help me.

Do you a print button on the form which is being clicked to print the form ?
If you do, then there is a way to suppress the printing. Otherwise, I don't know of any way of solving your issue.
If you do have a print button, add the following code to the click event of the button:
var result = form1.MainPage.execValidate();
if(result==false){
xfa.host.messageBox("Please ensure that all validations are complete before printing.");
}
else{
xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);
}
Where "form1" is the rootnode of the form and "MainPage" is the page which contains all the subforms in your form. the exeValidate() method fires all the validation messages in the form and returns a true if the all validations pass the test. Otherwise it returns false.
Pleaselet me know if you have any other questions.
Thanks,
Armaghan.

Set your event picker to "PrePrint", Add your validation script.
Enter : xfa.event.cancelAction = (true) at the end of your "If" statement.

Related

Try to use "Enter" key to submit form

I ask your help Everybody. :-)
Here is a link to Playground.
The problem you can see if to look at the console or debug log.
If you fill the text fields and press "Enter" key, you can see that only the first field can get the value. Second one is NULL.
If you tap "Enter" key second time - there is no problem at all.
But if you clean fields and fill it up again - the same problem will be back.
If I use just a button with "execute" event - there is no problem.
Is it a bug or something wrong about my code?
I think the problem is that the changed value of the textfield is applied to the model only when the textfield looses focus (or after you pressed Enter). So yo have to set the liveUpdate property to true. Here is your playground example updated.
var userPhone = new qx.ui.form.TextField().set({
required: true,
placeholder: "00123456789",
liveUpdate : true
});

How to make quill editor required?

How to make the quill editor field required? The editor gets rendered into a div, but it isn't clear if there is a way to make the field/editor required when the form submits.
As you wrote, Quill works with a div and not with a form element so it can't help you with form validation.
You'll need to check manually if the editor's content is empty, prevent the user from submitting the form and show a message that this field is required.
You can copy quill contents to a hidden input element before submitting the form as shown in this example.
A custom form control is also a good way to go. You can try to workaround with Quill's event handler and getting the value of the form.
Then a custom form validator is also possible.
Check : https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html
I've been trying to work around exactly this problem too today, using Python for back-end and a hidden form-field (name='editor') to get the value from the quill container to the back-end. Ended up with not actually really a validator but working about the same:
if request.form['editor'] == '\"<p><br></p>\"':
flash("You cannot send in empty posts!")
return redirect(CURRENT PAGE)
else:
CODE EXECUTED IF EDITOR IS NOT EMPTY
Not sure what you're doing with the input on the editor or whether you're even using Python for backend but I hope this helps. "<p><br></p>" is what the console told me the standard input on empty submission was when getting the information out of the editor.
Good luck!
const yourText = '<div><br></div>';
const htmlTagsToRemove = ['<div>', '</div>', '<br>'];
function removeHtmlTags(data) {
let text = data;
htmlTagsToRemove.forEach(it => {
text = text.replace(it, '');
});
return text;
}
const newText = removeHtmlTags(yourText);
console.log(newText);

Angular doesn't restore null-but-valid input value on model change when input is invalid

I have run across a weird/confusing behavior with <input> and form validation.
Essentially, if input has an invalid numeric value (which sets form.$valid to false), if a model value is changed to null, it sets the $valid flag back to true, but doesn't change the value displayed in the input field.
I have created a plunker to illustrate. Follow these steps to reproduce:
Modify value of a cell to empty.
Click on save link (which saves null into model)
Input a non-numeric character.
Click on reset link (which restores null from model)
Observe that the input field is no longer invalid, but the invalid character is still there.
Is this a bug or am I doing something wrong?
EDIT:
I'm starting to believe that it is a bug. I "fixed" it by introducing another directive that forces "" value for null.
Here's a fork of the plunker above with the "fix".
EDIT2:
This was fixed in v1.3+
You code is working fine but you forgot to add a validation check at app.js
this.save = function(){
if($scope.mainForm.$valid && !this.get() == ""){
old_num = num;
}
};
You should only save the value when the form is valid.
However that is not a full prove solution as the entire form has to be valid in order for save to work. To further improve the algorithm, i suggest that you mark the validity of individual model and you check validity to the individual model.
Hope it helps
Had a similar problem, I solved it by first doing:
form.$rollbackViewValue() or form.field.$rollbackViewValue if it was .$invalid before doing any of my other reset code.
In your example, you could change to something like:
<button class="btn btn-link" ng-click="cellForm.$rollbackViewValue(); item[prop].reset()">reset</button>

how to make angular-xeditable edit state always enabled

I am using angular-xeditable to edit elements within a form. I would like to have all the elements in "editable" mode at all times, e.g. no "edit" button needs to be pushed before the user starts editing.
I have been trying to use the $show() in my controller to enable the elements in the form, however it seems like the elements goes into viewing state again for example when using "onaftersave" when trying to save the values etc.
How do I do in order to always be in edit mode where the user never needs to enable editing in order to start editing the values?
Possibly try adding shown=true in your html:
<form editable-form shown="true">
I had this same problem. Even when trying to $show() the form again at the end of my onaftersave function it still wouldn't work. I suspect the visibility is being hidden after the onaftersave function runs but I didn't actually check if that's the case. Here's how I got around it:
$scope.$watch('yourFormName.$visible', function() {
$scope.yourFormName.$show();
});
Now whenever the form visibility changes to hidden, it will just show it again regardless of when it changed.
If your form is already open, and you just want to keep it open after submitting, you can do this:
<form editable-form name="MyForm" onbeforesave="saveMyData()" onaftersave="keepFormOpen()">
and the function keepFormOpen() would look something like this:
$scope.keepFormOpen = function() {
return "fake error message";
}
What this does is essentially gives the form a fake error message after you have already saved your data. This fake error message will interrupt the forms closing process, but since it was called after you already saved your data, it won't affect the previous submit.
To really keep open the form we can do the following:
<form editable-form name="MyForm" onbeforesave="saveMyData()" onhide="MyForm.$show()">

dropdown list atk4 quicksearch

i try to populate a dropdown menu for quicksearch in mvcgrid my code is:
$g = $this->add('MVCGrid');
$g->setModel('materiale');
$g->addPaginator(25);
$s = $g->addQuickSearch(array('nome_mat'));
$value_list = array(
1=>'Granito',
2=>'Marmo'
);
$s->addField('dropdown','tipo_mat','Tipo_mat: ')->setValueList($value_list);
The dropdown list appear on quick search form.
My db field is tipo_mat, but when i click quicksearch button nothing uppens, can someone help me plase.
Thank's
You will find that the Quicksearch is nothing more that a simple form, which applies condition to your grid when submitted. In theory, you could have a standard form sitting in there doing the same thing:
$search = $g->add('Form',null,'quick_search',array('form/quicksearch','form'));
$search->addFiled('dropdown','tipo_mat')
->setValueList($value_list)
->set($_GET['tipo_mat']);
$search->addField('search','q')
->set($_GET['q']);
// Handle submit of form, reload grid with AjAX, pass values as arguments
if($search->isSubmitted()){
$grid->js()->reload($search->getAllData())->execute();
}
// If values are passed, use them
if($_GET['q'])
$grid->dq->where('name like','%'.$_GET['q'].'%');
if($_GET['tipo_mat'])
$grid->dq->where('foo',$_GET['tipo_mat']);
The "Filter" and "QuickSearch" classes help you with saving search values but you must not be afraid to look into their source and create your own QuickSearch class which can apply parameters properly.
Perhaps using Filter in your case is better than quick search, because of how "applyDQ" is handled:
https://github.com/atk4/atk4/blob/master/lib/Filter.php#L62

Resources