Download & Extend

Name of the field of multigroup for form_set_error

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 multigroup

it 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");';
             }
            }}
            
?>

<?php
if ($s!='') :
?>

$(function(){

<?php
print $s;
?>

});

<?php
endif;
?>

#4

Status:active» postponed (maintainer needs more info)

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:

<?php
form_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.

nobody click here