Hi world,

Content.module file has a section where the following is written.

within: function content_field($op, &$node, $field, &$items, $teaser, $page)

"case 'validate':
// TODO: here we could validate that the number of multiple data is correct ?
// We're controlling the number of fields to fill out and saving empty
// ones if a specified number is requested, so no reason to do any validation
// here right now, but if later create a method to indicate whether
// 'required' means all values must be filled out, we can come back
// here and check that they're not empty.
break; "

how does one go about doing the TODO for this? Can anyone please clue me into where to begin?

Comments

sabweb’s picture

OK, so I have narrowed it down to this,

within the "case 'validate':

I have entered
if (obviously true condition) {
form_set_error('field_name][i][value', t('Your message'));
}

but it is being called more times than the determined quantitiy of items?

Does anyone know what would be calling this?

sabweb’s picture

Yep, the solution is to inspect the item that is being validated, check it's value and then set an error if it doesn't comply.

Do a var_dump($node) to check out what variables you are dealing with, then you can also mess with $item, $field etc which are being passed to the function and voila!

Hopefully this will help someone out there?