Home > form validation > Drupal validation for nested field element

Drupal validation for nested field element

March 25Hits:3
Advertisement

I have written some custom validation for each element in a form. I use the following method to display errors. It automatically highlights the required fields.

form_set_error('field_athletes_male', 'Athletes Male field is required.');  

My problem is that there are nested element names like this:

 field_coaching_programme[und][0][field_organisation_delivered_by][und][0][value] 

The validation message is shown successfully but the element is not highlighted.

Answers

Its working now, code as follows

form_set_error('field_coaching_programme][und][0][field_organisation_delivered_by', 'Organisation delivered by field is required.');

Related Articles

  • Drupal validation for nested field elementMarch 25

    I have written some custom validation for each element in a form. I use the following method to display errors. It automatically highlights the required fields. form_set_error('field_athletes_male', 'Athletes Male field is required.'); My problem is

  • Validation Errors with Form Element on Node FormAugust 8

    I'm creating a custom field element type that contains other interactive elements. I've been following the Drupal core File module to try to simulate some of the functionality of it. One thing I've been having trouble with is submission and validatio

  • How can I skip field validation if the field is hidden?December 12

    I get a node form with node_form and then I render it with some modifications. One of the modifications is that I duplicate the fields so I have the same fields twice. One field is disabled and the other same field is enabled, I also have a checkbox

  • How do I skip validation for node form element?December 21

    I have a content type having 10 fields that are all required. How do I skip validation for some fields? Is there any hook/function that allow me to do this? --------------Solutions------------- For deciding and skipping some fields after submit follo

  • Disable validation of HTML5 form elements

    Disable validation of HTML5 form elementsJune 22

    In my forms, I'd like to use the new HTML5 form types, for example <input type="url" /> (more info about the types here). The problem is that Chrome wants to be super helpful and validate these elements for me, except that it sucks at it.

  • jQuery Validate - Enable validation for hidden fieldsDecember 11

    In the new version of jQuery validation plugin 1.9 by default validation of hidden fields ignored. I'm using CKEditor for textarea input field and it hides the field and replace it with iframe. The field is there, but validation disabled for hidden f

  • Nested Field Collections + PHP

    Nested Field Collections + PHPJune 20

    I have a Field Collection called "Tab Content" which contains fields such as title, body, and a nested Field Collection called "Content Sidebar". The idea is that you can enter information that populates into a tabbed interface. In eac

  • Can any ECC field element be safely serialized as "compressed" and then restored as uncompressed?July 24

    I have a library that stores all its ECC Field Elements in uncompressed form, in a bloated Base64 XML format, and storage has become a concern. (We want to support QR code as a form factor,etc) Rather than ask the crypto library authors to support co

  • Change values of nested fields with entity_metadata_wrapperJanuary 16

    The background of this question is that I'm trying to migrate data from Drupal 6 Imagefield Extended to Drupal 7 File Entity (with File Entity Inline). See also https://www.drupal.org/node/974888 First I tried to understand how entities work and how

  • Element cache does not allow nested terracotta elementsJanuary 25

    When I added terracotta configuration into ehcache.xml, I encountered following error. I think libraries conflicted, but I did not found which one of them? When I remove terrracotta configuration, project works. Caused By: org.apache.shiro.cache.Cach

  • Complicated Validations with Many Fields in RailsFebruary 17

    I have a model (ProjectedSquad) that belongs to another model (SoldierBio) with many different foreign keys. I want to validate that certain fields have a uid value that only appears once in the row, while other fields do not need to have a unique va

  • Incrementing a nested list elementAugust 1

    I've been wanting to increment a nested list element of which I know the "coordinates". I thought of the following procedure, using Apply with Part. test = Table[10 h + 5 i + j, {h, 0, 3}, {i, 0, 1}, {j, 0, 4}]; pos = {4, 2, 3}; Increment[test[[

  • Please explain the Field Element Aggregation attributeAugust 4

    I am not quite understanding the use of the Field Element attribute 'Aggregation'. The Field Element : Defines the internal data types used in the list infrastructure of a SharePoint Web site. The 'Aggregation' attribute : Aggregation = "sum" |

  • How do I add a div after every field element on the node edit form?October 2

    There are two approaches that have failed: In the theme, add a theme hook for the node edit form. Then, create a template file for the node edit form. This won't work for my case, because the form is rendered in the template file with drupal_render_c

  • validations for text fields like country, State, citiesJune 4

    What should be proper validations for text fields like country, State, city i.e. can it be only characters or alphanumeric or can it also include special characters --------------Solutions------------- It really depends on your project. I'll try to g

  • How do I rewrite the ID of an exposed filter field element?

    How do I rewrite the ID of an exposed filter field element?January 12

    I am desperately trying to a way that I can rewrite the ID of an exposed filter field element. I've gotten so far as to set up hook_form_alter where I can get the specific $form array that I need. When I look at that array using dpm($form) I can see

  • Extract final value from nested field collectionOctober 28

    I have a content type with a field collection. This field collection has, as fields, other field collections. It works well, it groups the content for a node perfectly, but when trying to extract the data programmatically, I cannot access the values

  • Aggregation on nested field not workingJanuary 14

    Im unable to do an aggregation on nested documents. Here are 2 of the sample documents: document 1 { "name": "Samuel Lone", "assignments": [ { "subject": "data structures", "score": 43, "dep

  • Create an array of nested field in PyTablesJanuary 18

    In PyTables I have the following table schema: class ElectrodeTableDescription(tables.IsDescription): ElectrodeRatio = tables.Int32Col() ElectrodeRatioMax = tables.Int32Col() class StimSetTableDescription(tables.IsDescription): InterStimulusInterval_

  • Remove validation from entry fieldJanuary 20

    I have a form that has been built where the div "TotalDayOutofOffice" automatically calculates based on the two dates that have been provided. The problem is, the validation on this field does not allow for decimals to be added, so if someone wa

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.600 s.