We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [validation]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
22 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 ...
0
votes
0answers
15 views

entry-field that is only editable on entry-creation and contains unique string

I have a text field that is used as a text-handle for linked entries. So it must not be changed after other entries reference it. It should be editable only on the creation of the entry and validated ...
1
vote
1answer
195 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
33 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
129 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
58 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
1answer
192 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
0answers
287 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
76 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
332 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
296 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
170 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
134 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
413 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
182 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
153 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
51 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
151 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
80 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
183 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
118 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
286 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
152 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
371 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
449 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
152 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
610 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
405 views

Craft Commerce: Custom address model validations

How/Where/Can I add more address model validations than just "firstName" and "lastName"...?
1
vote
1answer
67 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
104 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
315 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
178 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
238 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
234 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
185 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
117 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
426 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
38 views

Logged in after email validation

Is it possible to login automatic the user right after he validate his email address
2
votes
1answer
40 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
139 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
305 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
672 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
491 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 ...
3
votes
1answer
68 views

A plugin to validate a field depending on another field's value

I have an Assets field which I want to be required only if a separate Lightswitch field on the same Entry is 'on'. I'm currently trying to implement this with a simple plugin that creates a custom ...
6
votes
1answer
1k views

How can I add custom validation rules to my plugin settings?

I have a plugin that needs to perform some custom validation on one of its settings. How would I go about doing that?
1
vote
1answer
54 views

Select statement validating as true when no value selected?

I have a plugin with record and model both setting required to true for a frontend form entry: 'fieldName' => array(AttributeType::Name, 'required' => true), However it is still validating ...
2
votes
1answer
1k views

Entry Form Validation on Front End Form

I have a front end form based on the entry form example provided by craft documentation which allows logged in users to submit an entry to a specific section. Form validation is not working in that ...
2
votes
2answers
900 views

Translate field name displayed within validation error messages?

I'm adding validation errors to fields using addErrors($record->getErrors()) which then read like e.g. "My Field cannot be blank." But I'm wondering where I can translate the field name, which I ...
0
votes
1answer
315 views

Error with model validation

Hi I'm getting this error when I try to validate a model. Craft\mymodelModel and its behaviors do not have a method or closure named "getTableSchema". I'm using the following code in the controller ...