I'm trying to create a custom fieldtype that's display_field() function produces a collection of <input> boxes. The problem I am having is that the validate() function in my ft.x_fieldtype.php file is getting run each time for each <input> it seems.

Can anyone see a way around this?

  • What are your input names for all of your input boxes? Commented Aug 15, 2013 at 16:34
  • That was my first question too. For multiple input boxes there should be an array of fields all sharing the same name. Commented Aug 15, 2013 at 16:44
  • I have <?= $field->field_name ?>[credit_card][expiration_month] ?> and <?= $field->field_name ?>[credit_card][expiration_year] ?> for example for each of the name="" parameters. Commented Aug 15, 2013 at 16:47
  • It might be due to the nested array you have. Maybe try <?= $field->field_name ?>[credit_card_expiration_month] ?>? Commented Aug 15, 2013 at 16:49
  • That didn't seem to help. Can you think of an example fieldtype that does multiple fields but only requires one validation call? I was looking at matrix but since it validates each column what I am seeing is an expected behavior. Commented Aug 15, 2013 at 17:11

1 Answer 1


One solution I came up with is to set an instance variable such as $has_already_validated to prevent further validation. It seems to work as there is only one instance created at least. Here's an example:

class My_fieldtype_ft extends EE_Fieldtype {
    private $has_already_validated = FALSE;

    function validate($data) 
         if ($this->has_already_validated) return TRUE;
         $this->has_already_validated = TRUE;

         // your validation code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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