Angular reactive form custom validation - forms

I am trying to make reactive form custom validation, From multiple set of inputs [text-boxes, radio button, select], Form get validated with true when any two input fields are filled or entered.

For custom validation in form , you can set flag by check form control value in if condition and display message in HTML with that flag.
Example:
In the TS file:
flag:boolean;
if(this.demoForm.value.phone && this.demoForm.value.pin){
this.flag=false;
}else{
this.flag=true
}
In HTML file:
<span *ngIf='flag'>Your form is invalid</span>

Related

TYPO3 EXT:powermail prefill or preselect a field via url

I have my own TYPO3 plugin that displays records. Now I want to add a link to a second page to each record.
The second page should be a powermail form. Now I want that the link to the second Mail contains a parameter that should prefill a input field in the powermail form.
Is that possible? And if so how?
Yes it is possible. See documentation of powermail: https://docs.typo3.org/typo3cms/extensions/powermail/ForAdministrators/BestPractice/PrefillField/Index.html
The standard way
Prefilling (input, textarea, hidden) or preselecting (select, check, radio) of fields will be done by the PrefillFieldViewHelper. It listen to the following methods and parameters (in this ordering):
GET/POST param like &tx_powermail_pi1[field][marker]=value
GET/POST param like &tx_powermail_pi1[marker]=value
GET/POST param like &tx_powermail_pi1[field][123]=value
GET/POST param like &tx_powermail_pi1[uid123]=value
If field should be filled with values from FE_User (see field configuration)
If field should be prefilled from static Setting (see field configuration)
Fill with TypoScript cObject like
plugin.tx_powermail.settings.setup.prefill {
# Fill field with marker {email}
email = TEXT
email.value = mail#domain.org
}
Fill with simple TypoScript like
plugin.tx_powermail.settings.setup.prefill {
# Fill field with marker {email}
email = mail#domain.org
}
Fill with your own PHP with a Signal. Look at In2codePowermailViewHelpersMiscPrefillFieldViewHelper::render()

CKeditor used on form input

Is it possible to use ckeditor on a form input instead of textarea, i am building a CMS and now trying to add ckeditor and majority of of fields are form input not textarea
Thanks in advance
You can use CKEditor on an element (a div, say) that has contenteditable set. In fact, by default contenteditable elements will have CKEditor editors instantiated. It seems unconventional to use a rich text editor on an input of type text but I imagine it could be done.
As far as I know CkEditor has to be created using a textarea. In saying this, I am using it in a Razor MVC view and its one of the classes in my form..
The request will be blocked though and you will get this error;
A potentially dangerous Request.Form value was detected from the
client
To get around this, you need to get the value of the CKEditor text and html encode it. You can do this
when submitting your form, intercept it on the onsubmit function:
<form id="myform" onsubmit="javascript:onFormSubmit(this);return false" >
...
</form>
Then in this onFormSubmit function
Get the value,
Set the property value to the url encoded value
Do a ajax call to your server with the data
Your function will get the CKEditor encoded value like so:
function onFormSubmit(form)
{
var editor = CKEDITOR.instances["EditorId"];
var richtextValue = editor.getData();
var urlEncodedValue = encodeURIComponent(richtextValue);
// TODO rest of code doing ajax post to submit your form and its data
// Here you need to do an ajax call to your server pass it the form data along with the url encoded CKEditor value for that property
}

How to send multiple forms with one button in Contao?

I have a question about the wrappers/accordeons. I now have multiple wrappers and in each wrapper there is a form. Now, I want one sendbutton on the end of the page. The sendbutton which will send all the forms that have been filled in at once.
How can I do that?
I don't know why you want to break input into different forms and then submit them again at once. Would it not make sense to use one form and submit the data and process it the way you want using the processFormData hook? may be because you want the accordion to group you form fields. Let me help you this way:
Create your form in the format shown below. Make sure the form has a tabless layout to be able to use fieldsets.
Create a fieldset without a label. You may add the class ce_accordion just in case you have some styling attached to it.
Create a field of type html and add the following markup.
<div class="toggler">Form 1 headline here</div>
Create another field with the following markup
<div class="toggler">
Now create your input fields from here. for example a text field,textares.
Create a field of type html to close html markup created in step 3
</div>
Create a fieldset wrapper end here.
The above steps can be repeated as many as how many groups of fields you want to create in an accordion.
Now create you submit button here and it will send all your data the way you want.
Just a by the way:
If some one submits a form in a wrapper that is closed, how will he know which wrapper has error fields?
$(document).ready(function() {
$(".ce_accordion").each(function(index,el) {
if($(this).find("p.error")){
$(this).addClass("hasErrors");
$(this).find("div.toggler").addClass("active").attr("aria-expanded","true");
}
});
​});​
You can now add a style for .hasErrors rule

Form submit button to email based on a fields value

I'm creating a PDF form with a submission button. I would like the form to email based on the value of another form in the field. I'm assuming I need to do an "IF...ELSE" statement, but keep getting a syntax error that I cannot figure out. I am completely java illiterate.
This can be done using multiple solutions, but you do need to program Javascript inside of the PDF. You can use if-else on-click of the email-button. Here you can check values entered inside of the PDF form:
if (this.getValue("somefield") == "left") { emailvalue = "toA#domain.com" } else { emailvalue = "toB#domain.com" }
But you could also set the value onBlur or onFocus of a certain field. Like with radio-buttons the onBlur is useful because you know the user clicked or focused on this field and so set the variable emailvalue to a certain value.

form doesn't appears in custom template page

I am newer to wordpress.i have created a form using form builder.and included in a page.The form displays in the default template but not in the custom template.any idea??
// Formbuilder manual form display. Replace the # in the following line with the ID number of the form to be displayed.
if(function_exists('formbuilder_process_form')) echo formbuilder_process_form(#);
// End of FormBuilder manual form display.