Posted by Luciuz on January 28, 2011 at 3:54pm
5 followers
Jump to:
| Project: | Content Construction Kit (CCK) |
| Version: | 6.x-3.x-dev |
| Component: | content_multigroup.module |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Issue Summary
hi
for multigroup (cck3) with internal 'field_text' field i write:
for ($i=1; $i<count($what); $i++) {
if (!in_array($what[$i], $out)) {
form_set_error('field_text', t('error'));
}
}
//$what - array of the fields
//$out - array of valid values
//($i-1) - indexs of fields in multigroupit works for ordinary cck field which named 'field_text'. How to write the first parameter to form_set_error for each field in multigroup? Ty
Comments
#1
Also this is the problem of ordinary multiple fields
#2
for form_set_error
'field_text' <=>(is equal) 'field_text][0][value' //[_error_element]
'field_text' (in multigroup) => 'group_name][0][field_text][value' //for text field in 0 group
but it does not work
#3
i tired and i wrote code in form-page (temporarily):
<?php
$s='';
$errors=form_get_errors();
if (count($errors)>0) {
foreach ($errors as $field => $error) {
if (preg_match('~field_text~', $field)) {
$s.='$("input#edit-group-name-'.preg_replace('~[^\d]~', '', $field).'-field-text-value").addClass("error");';
}
}}
?>
<?phpif ($s!='') :
?>
$(function(){
<?phpprint $s;
?>
});
<?phpendif;
?>
#4
I have no idea what you are trying to accomplish here. Sorry.
#5
I hope this saves you all some time:
to target a specific field that is part of a multigroup, you can do the following:
<?phpform_set_error('field_name][i][value', t('Your message'));
?>
Where field_name is the machine-readable name of the field and i is the index in the multigroup, starting from 0. You do not have to include the multigroup name.
#6
Thanks @andirez!
#7
Karen, I believe Luciuz was trying to report the difficulty in setting a form error on a multigrouped cck field. Andirez has a functioning answer, but it's clearly a hack.