Questions tagged [validation]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
23 views

Missing field validation on user account edit

I've been implementing a user account page with Craft Commerce and copied over the template found here: https://docs.craftcms.com/v3/dev/examples/user-profile-form.html#simple-profile The issue is ...
1
vote
2answers
51 views

How to show flash message for Commerce order when changing status on listing page?

If I change an order's status to "Cancelled" (my custom order status I created), I want to ensure that the CP editors provide a "Cancellation Reason" from a dropdown field in the order. I've set up a ...
0
votes
0answers
28 views

Craft CMS User Registration Form Validation

I have enabled fron end registration form, I want to make firstName and lastName required in the form and also want to add custom fileds with required validation.
1
vote
1answer
24 views

Normalize then validate unique entry in a custom module field

I have a custom text field in a module that the user populate with an EAN number. The input is getting validate by a "match" validator and then is serialized before save to get ride of the various ...
1
vote
1answer
48 views

Server-side address validation in Craft Commerce 3

Was wondering how to do this in Commerce 3 as there were a few different older methods discussed here.
1
vote
0answers
34 views

Sanitize form input

I'm trying to sanitize form input values in my plugin. Yii2 framework provides the following validation method: https://www.yiiframework.com/doc/guide/2.0/en/tutorial-core-validators#filter It says ...
1
vote
1answer
58 views

Frontend form validation

I need to validate the form submitted at the frontend by applying additional validation rules. For that I have created the plugin that listens to "EVENT_BEFORE_SAVE_ENTRY" event and should validate ...
1
vote
1answer
119 views

How do I show errors for a new front end entry form?

I'm using a front end form so logged-in users can create a new entry ("post") or edit an existing entry. Here's the controller for figuring out whether it's a new or existing entry: {# Get the entry ...
1
vote
1answer
485 views

How to validate a form request

Is there anything with craft like Laravel's Form Requests? I am writing a plugin with a custom entry type. Right now, I am doing the store/edit pages and I do not want to reinvent the wheel ;) Is ...
1
vote
1answer
36 views

Field formatting

I'm looking for a way to restrict how a field gets formatted. I have a channel for a podcast that should always be in the format of hh:mm:ss - despite the instructions making this clear, editors tend ...
1
vote
1answer
172 views

Craft Rules and Validation

Some of the changes in craft 3 have been killing me. I know Yii does validation using the public rules function. Here is a rules function I grabbed from the MatrixBlockType model. function rules() { ...
1
vote
1answer
89 views

Do field values get serialized before validation?

I am learning to write my first plugin for Craft CMS 3.x I have a field that gets displayed as a string, but is stored in the database as binary. When I validate it, I write: public function ...
2
votes
2answers
346 views

How to validate a unique field in Craft 3 element?

I'm trying to validate a custom Element in my Craft 3 plugin. Where should I be putting my validation rules? I have two classes: one for the Element, one for the ActiveRecord (e.g. Invoice and ...
4
votes
1answer
422 views

Craft 3 Custom Plugin: model validation

Struggling a bit here - have created a custom plugin where I want to validate form submission against a predefined model before saving to the database. All pretty straightforward so far … However, if ...
1
vote
1answer
97 views

How can I set a custom URI for the confirmation link of account email update from a front-end form?

I have a front-end form to update user's email address, like this example: <form method="post" accept-charset="UTF-8" enctype="multipart/form-data"> {{ csrfInput() }} <input type="...
1
vote
2answers
492 views

Craft Commerce — Billing / Shipping Address validation / required Fields

As default Craft has only First Name and Last Name as required. Is it possible to set more as this two fields as required fields? And is it also possible to set custom Fields as required too?
2
votes
1answer
381 views

Title field character length

Is it possible to limit the title field in an entry? As with other fields I can adjust so that it only takes a certain amount of characters.
2
votes
2answers
264 views

Craft Commerce: make address phone telephone field required without JavaScript

Because I used a similar address model to the one supplied in the Craft Commerce templates, which essentially uses the same form partials for both address and billing, and also hides and shows the ...
1
vote
1answer
144 views

Show all form errrors using amforms

I'm using amforms and would like to display all form errors at the top of my page, not just per field. I can't seem to find the answer in the docs. Is this option available?
2
votes
1answer
474 views

How can I validate a Redactor rich text field in a front-end form using the VeeValidate Vue.js plugin?

Scenario I'm using the VeeValidate Vue.js plugin to validate a Craft front-end form that contains a Redactor rich text field. Problem Validation of the rich text field fails because Redactor adds ...
1
vote
1answer
192 views

AttributeType::Number giving validation error “Must be an integer”

So I have a model attribute attributeName with an AttributeType::Number I haven't implemented any personal validation rules yet, however when I run: model->validate(), its giving me a "...
3
votes
2answers
207 views

Validation on username?

Just wondering if theres anyway to force some validation on the username? I have usernames being displayed locally, and therefore I'm trying to prevent email addresses being used. I have my client ...
2
votes
1answer
54 views

onBeforeSaveUser event does not fire if basic user fields do not validate

I have additional fields I check for in the onBeforeSaveUser event and add the errors to the errors array. The problem is my code doesnt even run if they miss the main fields or if the email is ...
1
vote
1answer
163 views

AttributeType::Handle Validation and Unique

I'm building a plugin that has a column in the DB which is unique and essentially an AttributeType::Handle. Here is the piece from the record: return array( 'key' => array(AttributeType::...
1
vote
0answers
102 views

How to set other fields as required in Craft Commerce checkout process? [duplicate]

I'm using Craft Commerce with the default checkout template. At the step of completing addresses, only First Name, Last Name & Country are required fields by default. As I'll sell non-digital ...
2
votes
2answers
202 views

Front-end registration validation

I have a front-end registration page and need to change the validation to add (minimum characters for information on the page and to make fields to accept only letters and other to accept only number ...
1
vote
1answer
121 views

Change password on user profile (customer account in Craft Commerce)

I have a customers area as part of the Craft Commerce site I am working on. Ideally I want the user to be able to update their password from their customer profile screen. I have it working and ...
1
vote
1answer
320 views

Password validation for resetting password

I have the following code to further validate passwords when creating/registering an account which is working fine. However, when trying to use this same validation for resetting a password I am not ...
4
votes
2answers
172 views

How do I include record relationships in validation?

Say I have a record defining a foreign key relationship which is set to required, such as: public function defineRelations() { return [ 'type' => [ static::BELONGS_TO, ...
0
votes
1answer
399 views

Front-end entry field validation problem

I have this simple code: <form method="post" accept-charset="UTF-8"> <input type="hidden" name="action" value="entries/saveEntry"> <input type="hidden" name="redirect" value="...
3
votes
1answer
459 views

How do I write custom model validators for my plugin that refer to other fields?

I'm looking at this guide to writing custom validators: https://experiencehq.net/blog/the-definitive-guide-to-validation-in-craft-part-5-custom-validators However, this only allows code that refers ...
1
vote
2answers
321 views

Validating Date of Birth format from a form field value

I'm working a on website project which includes a web form which asks for various personal details, one of the fields on the form is Date of Birth. The form is being validated by a custom plugin ...
1
vote
1answer
721 views

Form field validation

I am relatively new to Craft CMS and have been using the formBuilder2 plugin to create forms. No problem this far. I have been able to use ElementApi to output the forms into Json. Still no problem. ...
3
votes
1answer
442 views

Craft Commerce: Custom address model validations

How/Where/Can I add more address model validations than just "firstName" and "lastName"...?
1
vote
1answer
73 views

Model validation not run when using EntriesService saveEntry method

Currently i have to validate my model before saving because of some custom validation rules setted on the model which won't run when using the EntriesService saveEntry method. This causes a two step ...
0
votes
1answer
110 views

Custom Validation Message for numeric

I want to Number validation for my site, but not able to show custom validation message to user. 'CVV' => [ 'label' => 'CVV Number', 'type' => 'numerical', ...
3
votes
1answer
350 views

How can I repopulate a matrix field on a front-end form?

I have a matrix field on my front-end form. Everything is working properly, data is saved correctly etc. I am testing & trying to break things and I noticed I wasn't repopulating those fields if ...
2
votes
3answers
191 views

Entry validation not working when Publish live changes permission is not checked

when a user with no permission to publish is submitting a blank entry, the entry is saved anyway without any errors. Here is the permissions set to the user group: I have few required field as ...
1
vote
1answer
269 views

How can I repopulate my dropdown on a front-end form?

I am allowing guest registrations - everything is working fine. I am hung up on getting my drop down menu to repopulate/hold its value if there are any errors while submitting. I have a states field ...
1
vote
1answer
264 views

Validating date fields in a plugin's settings

I have a plugin that has some settings, some of which are dates. I want to make these fields required, and ensure they are valid dates. Because of this bug the date attributes are set as ...
0
votes
1answer
205 views

How can I make a product field required?

I have a drop-down of variants of a product. For example t-shirts: {% for purchasable in product.variants %} <option value="">Select</option> <option {% if purchasable.stock &...
2
votes
1answer
121 views

Handling non-image uploads when updating user photo from front-end form

We have a front-end form that allows users to update their profile photo. If a user attempts to upload a non-image file, instead of the actionSaveUser controller failing and throwing an error, it gets ...
2
votes
2answers
440 views

Passing data back to form on invalid submission

I currently have a form that is being displayed to the user via a custom route. The form submits to a controller. The first thing the controller does is populate a custom model and validates it. If ...
2
votes
1answer
42 views

Logged in after email validation

Is it possible to login automatic the user right after he validate his email address
2
votes
1answer
41 views

Is there a way to to fire some code before user validation?

Am wondering if there is a way to fire some code prior to user validation being actioned? I have code running in a plugin that fire onBeforeSave but validation is actioned before this. So was ...
6
votes
3answers
3k views

Programmatically update entry field

I'm trying to update an entry's field value from a Craft plugin. First I was trying to just update the attributes of the entry like so: $entry->getContent()->setAttributes(array( 'metaStatus' ...
0
votes
1answer
155 views

Base fieldtype validation working with model validation?

How can you ensure that the base fieldtype validation (required etc) and error messages are still applied when validating $value via the validate($value) function?? Validate method in fieldtype class:...
1
vote
1answer
350 views

Custom validation rules on frontend form

What would be the best way to add some custom validation rules on forms submitted on the front-end without using specific field types for it? I'm using the Guest Entries plugin that allows anonymous ...
2
votes
1answer
703 views

Contact Form Plugin: Validate if a checkbox is checked?

What is the cleanest way to validate if a checkbox (i.e. agree to legal terms) is checked?
2
votes
1answer
530 views

Entries Field Type Validation

I am having some issues understanding why validation is not working on my entry forms. I've got an entry with several field types which aren't of type "entries" and the required validation is working ...