Skip to main content
Commonmark migration
Source Link

If your form element is defined like that:

$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Using only last index would made setting errors ambiguous, thus it's not supported. At least officially. Might work, but only as an undocumented feature.

Formatting this string is described in API:

Parameters

 

$name: The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

If your form element is defined like that:

$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Using only last index would made setting errors ambiguous, thus it's not supported. At least officially. Might work, but only as an undocumented feature.

Formatting this string is described in API:

Parameters

 

$name: The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

If your form element is defined like that:

$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Using only last index would made setting errors ambiguous, thus it's not supported. At least officially. Might work, but only as an undocumented feature.

Formatting this string is described in API:

Parameters

$name: The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

added 417 characters in body
Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112

If your form element is defined like that:

$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Making it possible to useUsing only last index would made setting errors ambiguous, thus it's not supported. At least officially. Might work, but only as an undocumented feature.

Formatting this string is described in API:

Parameters

$name: The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

If your form element is defined like that:

$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Making it possible to use only last index would made setting errors ambiguous.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

If your form element is defined like that:

$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Using only last index would made setting errors ambiguous, thus it's not supported. At least officially. Might work, but only as an undocumented feature.

Formatting this string is described in API:

Parameters

$name: The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

Post Undeleted by Mołot
added 150 characters in body
Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112

First argument of form_set_error should reflect the element of the form array, without the outside [ and ]. If your form element is defined like that:

$panes['webform_nid31'][0]['contact_person']$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('webform_nid31][0][contact_person''panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Making it possible to use only last index would made setting errors ambiguous.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

First argument of form_set_error should reflect the element of the form array, without the outside [ and ]. If your form element is defined like that:

$panes['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

If your form element is defined like that:

$form['panes']['webform_nid31'][0]['contact_person'] = array( ... );

your form_set_error call should look like that:

form_set_error('panes][webform_nid31][0][contact_person',
                t('You must select a name for this group of settings.'));

You need to set full path to element, without outside [ and ]. You could have many "contact_person" fields in one form, just in different branches of a form tree. Making it possible to use only last index would made setting errors ambiguous.

Last but not least, actual output is defined in theme, it might well be something other than red border if theme author decided so.

Post Deleted by Mołot
Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112
Loading