hook_form_alter() is the hook implemented by modules to alter the forms implemented by other modules.

learn more… | top users | synonyms

0
votes
1answer
10 views

Hidden form values updated with multiple submission

I'm writing a backend validation function to prevent multiple submission for comments by logged in users in Drupal. Following is my code: function MYMODULE_form_comment_form_alter( &$form, ...
1
vote
1answer
49 views

How do I change text on submit button in the node form?

I'm trying to change the submit button text "Save and keep published", but with no luck. I'm using standard hook_form_FORM_ID_alter like this: function mymodule_form_node_news_form_alter(&$form, ...
0
votes
1answer
12 views

Custom validation for views exposed form using form alter

I want to add my custom validation to the views exposed filter form for that I have added below code in hook_form_alter $form['#validate'][] = 'xxxx_custom_form_validate'; But its being called for ...
0
votes
1answer
17 views

Overriding field label

I'm trying to override the label of the picture field. I've started with the code here: How to change the field label on my registration form? Drupal 7 function mymodule_form_alter(&$form, ...
-3
votes
2answers
36 views

How I can alter this form using another module? [closed]

function client_form($form, &$form_submit) { $form['Client_name'] = array( '#title' => t('Client Name'), '#type' => 'textfield', '#value'=> nameget(), //'#required' ...
1
vote
2answers
112 views

How to replace the search submit button with a Font Awesome character?

I would like to replace the search submit button with a Font Awesome character like the Magnifier (Search Icon) character, and put Search the site inside the search box. How can I achieve this? ...
3
votes
2answers
57 views

Add attribute to all textboxes in the site

The question is simple , in my theme I want to apply an attribute to all textboxes in whole forms . I know how to add an attribute to an specific element in drupal using hook_form_alter , but it is ...
0
votes
1answer
26 views

How can I tell Drupal to add autocomplete=off to the login form

I'm under pressure to close out some issues from a Qualys scan. One issue flagged was 150112 Sensitive form field has not disabled autocomplete Suggestions include adding autocomplete="off" to ...
0
votes
1answer
22 views

How to set multiple entity references as default values using the hook_form_alter()

I have a node which when renders an adds an entityform to the page. The node has a entity ref field which references multiple other nodes. (eg: Products A, Product B, Product C, etc) What I need is ...
1
vote
1answer
55 views

Is there a way to programmatically add questions to a webform grid?

I have seen hooks to use to alter webform options, but not the questions that appear on the left side of a grid. I would like those questions to be a node titles actually of a content type that I ...
0
votes
1answer
40 views

How to get value of Textarea in node add form?

In my node add form I have added one text area : function mymodule_form_alter(&$form, $form_state, $form_id) { if ($form_id == "contenttype_node_form") { if (!isset($node->nid) || ...
0
votes
0answers
16 views

How do I change field handler_settings within hook_form_alter?

I have an entity reference field that is inside of a field_collection (D8) and I need to alter it's views arguments during ajax load to pass in the value from a preceding field on the host entity. I ...
0
votes
0answers
8 views

How to alter a form for the translation of an entity?

Both hook_form_alter and hook_form_FORM_ID_alter in my module are getting triggered before the entityFormAlter in the ContentTranslationHandler. So the 'Delete Translation', which replaces delete is ...
0
votes
1answer
36 views

Add Legend to Text Format Fieldset

I'm working on making a site I maintain WCAG AA compliant. One of the items I'm getting flagged for is "Every FIELDSET element must contain exactly one LEGEND element." This error shows up on every ...
0
votes
0answers
18 views

Custom Vertical tab

I am adding a simple select element via form alter to the menu vertical tab on my nodes. In this select list the user can select an icon that should be displayed with the menu link. I have ...
1
vote
1answer
41 views

How do I modify a core field to use Ajax and add markup?

I am still getting the hang of D8... I have some entity types with various reference fields. I need to ajax in other values from another node type when changing the value of the entity reference ...
0
votes
2answers
39 views

Insert data in table using drupal form alter submit

I am currently work with a drupal's inbuilt form which is coming from it's system function. Now I added a extra field with value in the form with Drupal's custommodule_form_deal_node_form_alter(). It ...
1
vote
2answers
39 views

Add javascript to form by module

i am writing a module in drupal 8. I wish to add a javascript when loading that form. function ajax_example_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { ...
-2
votes
1answer
88 views

Shopping Cart view, change quantity widget to select box

I have two kinds of price type: price per unit and price per weight. I have managed to use hook_form_alter() to change the widget textbox to a predefined select list. For some items it fills the ...
0
votes
1answer
35 views

TWIG if/else to filter through templates

I am trying to write a TWIG else/if statement that loops through four different templates based on the number of customers are chosen from a list. So if a designer chooses 1 customer a certain ...
0
votes
2answers
19 views

dupal form: how to assign specific id to radio button using form api

I wanted to change id of radio button. But i dont know which attribute shall i use to do that. $form['entry.497535900'] = array( '#type' => 'radios', '#title' => t('Category'), '#options' ...
0
votes
0answers
23 views

price and total price

function module_form_alter(&$form, $form_state, $form_id) { if (substr($form_id, 0, 28) == 'uc_product_add_to_cart_form_') { $form['qty']["#title"] =t('Adults'); } if ($form_id == ...
0
votes
0answers
6 views

Prevent (all languages) being displayed in multilingual entity forms?

So i have entities setup with translations enabled some fields are "all languages" i.e. their not set to be translated. I don't want to have "(all languages)" on my form labels. How do i prevent or ...
0
votes
0answers
28 views

Add two multiple image upload fields plupload

This is the problem that i am facing. I have 2 content types which are company and vacancies. Vacancy has an entity reference of a company. Company content has a multiple image upload field called ...
0
votes
1answer
24 views

Open preview in new window/page

I'm using drupal 7. Normally, during the creation of a contents, the preview is added above the form. I would wish that the preview opens in a new window, and that it is separated from the form of ...
0
votes
1answer
27 views

An illegal choice has been detected. Please contact the site administrator.in dynamic select list dependent dropdown

using hook_form_alter and custom form elements below $form['get-quotes-shipping']['country'] = array( '#type' => 'select', '#options' => array('_none' => '- None -') + ...
0
votes
1answer
21 views

Adding Ajax on existing dropdown list

I added this code in my template.php function PORTO_SUB_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'rapporto_di_lavoro_node_form') { ...
0
votes
2answers
16 views

Is there any way to run hook_form_alter based on a form ’s class instead of it’s ID?

Is there any way to run a hook_form_alter based on a form ’s class instead of it’s ID? I have a class of commerce products and am needing to do form alterations on their add to cart forms. There are ...
0
votes
2answers
32 views

Access submitted form data in custom callback before hook_mail_alter()

I wan't to alter contact form recipient according to what user chose in one of the dropdown fields of my Contact form. I implemented hook_form_FORM_ID_alter() in order to add custom submit callback ...
0
votes
1answer
16 views

Added Classes showed in dpm but don't show up in the output HTML

I want to add some classes into my form (node/add/-- form) so I use hook_form_FORM_ID_alter but I don't know why the classes add to my field in the dpm() output but when I check the html output those ...
0
votes
0answers
25 views

Change text of validation error message of a field in user register form

On this page i want to change the text of the validation error message RIZIV number: the value may be no less than 10000000000. Its from field field_riziv_number How do i manage this?
0
votes
0answers
41 views

hook_form_alter() to make multiple fields as required

I am trying to make field(s) of Entity Form as required. The field(s) that I want to make required works fine when its one field but when I mention that a field(s) can accept unlimited values the ...
0
votes
1answer
23 views

Long text increase maxlength

I have added a textarea and i want to store more that 1024 characters in it. Long text is the field type that i have chosen but an error comes up saying :Keywords cannot be longer than 1024 characters ...
1
vote
1answer
43 views

How to add CSS class to password-strength and password-confirm on /user/register page?

I want to add a class to password-strength and password-confirm on /user/register page? I tried to alter the form but as these are made with js I could not change or add anything to them. How can I ...
0
votes
0answers
27 views

hook_form_FORM_ID_alter: add class to field? Not working as expected

I thought I could add a class to a field in a form using hook_form_FORM_ID_alter. But even after clearing cache multiple times with Drush (drush cc all) it's not working, even though I know the module ...
0
votes
1answer
28 views

Field with '#type' = 'hidden' in hook form alter doesn't show #id in the source and it's not possible to show it with jQuery

I put in my template.php an hook_form_alter function where I assign '#type'= 'hidden' to "field_bergamo". But I want to show it when in the select list "Provincia" of the same form I select the ...
0
votes
0answers
10 views

Adding #ajax to an existing dropdown menu

I'm trying to add the #ajax property to a dropdown menu on a node add form. If I add the following code to a hook_form_alter, the ajax triggers correctly (on blur the ajax circle spins next to the ...
3
votes
2answers
42 views

Render same field twice but with different name/id attribute

I have overriden user-register.tpl.php and in it I would like to render same checkbox twice (So that I can submit if either of them have been checked and they are the same I just need to display them ...
2
votes
1answer
58 views

hook_form_user_register_form_alter() does not customize user registration form

I have implemented a hook_form_user_register_form_alter(). function hook_form_user_register_form_alter($form, $form_state, $form_id) { $form['account']['name']['#description'] = 'This is your login ...
0
votes
0answers
18 views

Form framework doesn't render date type after ajax callback

I have an ajax callback which returns a date type input field. The problem is any other input type other than date is generated, but date type is not rendered at all. The title, and description is ...
0
votes
0answers
13 views

Create an article translation(s) via hook_form_alter?

I would like to submit an article in English but when I press submit button I would like to create its translation(s) as well. Can I do it with hook_form_alter? I have this now: /** * Implements ...
0
votes
1answer
23 views

Apache Solr form alter add custom fields in search form

I wanted to alter the apache solr search form by adding my own custom textfields, dropdowns. I tried using the regular form alter hook but it works only for the Core search i.e custom fields appear ...
0
votes
0answers
55 views

How do I set the #default_value of a select list to the first option?

I'm currently using hook_form_alter and $form['#after_build'] to try and set a term reference select list's default value to the first option in the list. I'm using the Reference Option Limit module ...
1
vote
1answer
106 views

How to retrieve a select box option and set the field's value to it?

I have a a taxonomy term select box (called "product_keyword") in a node that gets its options populated via the Reference Field Option Limit module. There are 3 other taxonomy term reference fields ...
0
votes
1answer
46 views

Prevent form rebuild on image upload

I have content type Gellery with two fields. Image (Multiple) Game Name (Entity Reference) I am setting Game Name in hook_form_alter. Lets say it is set to "Game 001". When image is uploaded, it ...
1
vote
1answer
20 views

Adding custom form to form_alter — help please

I've been trying for awhile to add a custom form to a custom module so as to make it show in drupal profile Edit page. Using the normal $form['submit'] messes up the other forms in the page, so tried ...
0
votes
0answers
16 views

Move scheduler settings to multipage field group

All fields for node creation are in multipage groups. Fields that I don't need like comment settings, menu settings etc. I've set access to false in form_alter or after_build. Only scheduler ...
0
votes
2answers
30 views

Custom edit user page

I'm trying to build an edit form for specific users. For one type of user I want to hide password field for example What I did is to create a module called profilechange. Into profilechange.module ...
0
votes
1answer
20 views

How can I edit a node field in view page?

I want to edit a node field in a view page. Drupal has the modules editablefields and Editable Views to support for editing fields in a view page but it conflicts with some modules. So I want to write ...
0
votes
1answer
66 views

Add #ajax to an existing form

I'm trying to add the #ajax property to the add form of a simple existing content type. I thought hook_form_alter would be the way to go, but the code below doesn't get me the updated results I'm ...