Home > form validation > How to use form_set_value for a select list field?

How to use form_set_value for a select list field?

November 8Hits:2
Advertisement

Drupal 7. in my validate form function, I use form_set_value to set the value for the field "statut_metier" to 'draft'

If my field is a text field, this code works :

form_set_value($form['field_statut_metier'][LANGUAGE_NONE][0]['value'], 'draft', $form_state); 

If my field is a list(text) field, with the key for the value 'draft' = 5

I can't manage to have the form_set_value function work.

Using Devel and dpm() I have search to reach this field value :

I have tried :

form_set_value($form['field_statut_metier2'][LANGUAGE_NONE]['#value'][0], '5' , $form_state); 

but it doesn't work.

Any idea ?

Related Articles

  • How to use form_set_value for a select list field?November 8

    Drupal 7. in my validate form function, I use form_set_value to set the value for the field "statut_metier" to 'draft' If my field is a text field, this code works : form_set_value($form['field_statut_metier'][LANGUAGE_NONE][0]['value'], 'draft'

  • Select the fields of a node using code

    Select the fields of a node using codeJune 1

    I'm new to Drupal, and I have some problems. I need to select some fields from a node (via code), and then process the data. [] Basically, I want to show the total of column "value", grouped by "category", but as each field's content t

  • How to have CCK "Select list" field on my content type?

    How to have CCK "Select list" field on my content type?July 22

    I want to include in my content type a CCK "Select List" field. Which module(s) should I enable so as to have it as a choice? Thanks --------------Solutions------------- You have to enabled Option Widgets, as well as Number and/or Text. Create a

  • Disable an option for the select form fieldAugust 26

    How do I disable an option in the select form field? $form['feed'] = array( '#type' => 'select', '#title' => t('Display of XML feed items'), '#options' => array( 'title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' =

  • dropdowboxes with pre-selected custom fields optios that filters the results according seach needsJuly 29

    In my site I have one custom post types with custom taxonomies: custom post_type=listings --> Category --> Tags Along with it, I have some custom fields to separate them by country, state, region. The problem is that I need too supply an efficient f

  • Views search for labels in select list fields with exposed filtersDecember 5

    I created page with Views 3 where users can find other user by entering data in several exposed filters. That works great, but I have case where user must be able to to enter text, to search by label in select list field. (It has key | label structur

  • "Select" form field depending from another "select" form field receives just a valueDecember 14

    I am working with a custom form using two "select" form fields where one depends from the other one. The second "select" form fields receives only one value. What is wrong with the code I am using? function _load_province() { $province

  • Use multi-select lookup field as filters in a data view web part (DVWP)February 11

    i have a list and a doc library. the list has a multi-select lookup field to the ID field in the doc library. when a user chooses multiple values in the dispform.aspx list form, i want to display the corresponding documents beneath it. so, if a user

  • How to cut (select) a field from text line counting from the end?February 13

    I know how to select a field from a line using the cut command. For instance, given the following data: a,b,c,d,e f,g,h,i,j k,l,m,n,o This command: cut -d, -f2 # returns the second field of the input line Returns: b g l My question: How can I select

  • User name list in Select Option fieldJune 9

    I am using webforms and I want to add a Select Option field with the list of all authenticate user names. And if any new user add in my site than it will add automatically in that list Is that possible? if yes than how? --------------Solutions-------

  • What should I consider when selecting a field-of-view (FOV) for a space game?June 25

    I am making a space game (like the game Freelancer). You control a space ship in third person. What are some gameplay considerations that I should weigh when selecting a field-of-view (FOV) for such a game? --------------Solutions------------- There

  • How to display Select Files field using Low VariablesJuly 19

    I have a Low Variable titled lv_accreditations to allow the client to select a series of logos to display in the site footer. The variable is set to Enable Early Parsing and to output a comma seperated list. However, i'm unsure how to actually displa

  • Is it possible to populate a select list field from another grid field?November 20

    I'm working on a project where the client wants to be able to upload new page background images and then select one for each page/section of the site. A solution I thought might solve this would be to have a grid field allowing for the uploading of t

  • selecting a field when you cannot count from the start February 9

    This question already has an answer here: How to cut (select) a field from text line counting from the end? 2 answers I have a long file ( 20000+ lines) where each of the lines is a description of a book: book_number "title of the book" size typ

  • How to set default value of select list field on add node form?April 10

    I am trying to set the default value of a select list field on a node add form. The field name attribute in the HTML of the form is: field_state[und] The ID of the add form is: local-affiliate-node-form I created a little module to try to do this. It

  • Selecting Specific Fields in Entityform to DisplayAugust 6

    Goal: Create a single entity form whereby the the fields that the user sees and can enter information into depends on the tab that they're on. Approach: I am trying to create a views for each tab. I want to select the field that show up and then crea

  • How to send email after filling the selected list field

    How to send email after filling the selected list fieldSeptember 8

    Actually this is my content and i have one select list field in that when i select a "new litter" and click on save.I have to generate a email to author,when i select remaining else and click on save no need to generate email. --------------Solu

  • sending mail for select list fieldSeptember 10

    I have created a content type in which I have a field as field_result of type select list with options as; pass fail hold postpone When user selects the pass from select list and update or create a content, email should be sent to all admin users and

  • Get options from a select custom fieldDecember 4

    I've created a select custom field with different predefined values. I've done this using the Types extension for WordPress. Now I'd like to create a function to retrieve all the values that this select can have (not the value for the specific post,

  • Exposed filter : search term with select which 'field' to search by

    Exposed filter : search term with select which 'field' to search byDecember 31

    I have a view which displays a list of nodes with exposed filters. Everything works perfectly. I would like to add a filter like this: one input text one drop-down. The list items represent fields of content type. The user can write a search term in

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