Firstly, thanks very much for the help I've already had from members here. It's been straightforward and easy, even for a newbie like me, to understand.

At the moment, I'm working on editing one of the last pages on a client's site, the Contact Us page and am hoping to be able to use the Pixel & Tonic, Contact Form plugin. But, after some inspection of the Readme and the files that run the plugin, I have been unable to find the following:

1) How do I create/edit the error messages that the form generates?

2) Can I use the form to allow a user to enter their phone number? If so, what should the code look like in the template?

I would like the final form to look like the screenshot below.

Contact Form Preview

Any help that anyone can provide would be most appreciated.

With kind regards,



Thanks to this post, I've realised how easy it is to add a new field for the phone number (and assume I add the code wherever I want the new field to appear(??)), but am still clueless about the error messages.


I found it! It took quite a bit of digging about, but eventually I found the files I needed to edit. In case anyone else is struggling with this same issue, here's what you need to do:

Look in the folder 'craft/app/framework/validators/' for a file called 'CRequiredValidator.php'. Open the file in a text editor and look for the text: 'cannot be blank'.

Part of this line reads: '{attribute} cannot be blank.'

You can change the text 'cannot be blank' to whatever you like and can move '{attribute}' to after the alternative text that you've put in without breaking anything. Save and upload your altered file to the correct location.

Now, look in the folder 'contactform/models/' for a file called 'ContactFormModel.php' (probably the only one there).

By default, it has the following written into it:

    return array(
        'fromName'          => array(AttributeType::String, 'label' => 'Your Name'),
        'fromEmail'         => array(AttributeType::Email,  'required' => true, 'label' => 'Your Email'),
        'message'           => array(AttributeType::String, 'required' => true, 'label' => 'Message'),
        'messageFields'     => array(AttributeType::Mixed),
        'subject'           => array(AttributeType::String, 'label' => 'Subject'),
        'attachment'        => AttributeType::Mixed,

The bits you need to alter to complete the customised error messages are found after 'label' =>

Save and upload your second altered file to the correct location, and check out the new error messages for your form!

  • Note that by doing this you're changing that message for every required field in Craft, not just the Contact Form plugin. It's definitely not recommended to manually change any files in craft/app as they can/will be overwritten at any time by an auto/manual update.
    – Brad Bell
    Feb 19 '16 at 17:18
  • Thanks, Brad. It's a good point, but the default error messages were so clunky. Would you be able to point me towards a better method? Another problem with my method was that I've now broken the translation of the error message.
    – SYPOMark
    Feb 19 '16 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.