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

learn more… | top users | synonyms

0
votes
0answers
10 views

Skip save of field collection attached to entity without removing reference to field collection?

I've got a node form encumbered with many field collections and node save takes forever. I would like to "lock" some of those field collections and forgo saving them on node save. Kind of like ...
1
vote
1answer
20 views

An invalid implementation mymodule_form_alter was added by hook_module_implements_alter

I am trying to have my module alter menu_ui functions. Changing my module's weight didnt help and I read that hook_module_implements_alter is the way to go. So, as described here I am appending my ...
1
vote
1answer
14 views

How to alter a form base on the users' request info?

I would like to customize a form base on the users' request info in a page callback. I use drupal_get_form (or node_add for node create form) to get the renderable array, but most changes to the array ...
2
votes
2answers
31 views

White screen of death in hook form alter

I have enabled simplenews module in drupal 8 and I am trying to reduce the width of input field from 60 to 30. I am trying to implement form alter hook and have devel module installed. I used ...
0
votes
1answer
26 views

Alter form value in submit_preprocess

How do I change a value, in this case the title field of a node object form, in the preprocess function of the form_alter hook. $form['actions']['publish']['#submit'][] = MODULE_submit_preprocess'; ...
2
votes
3answers
43 views

How do I find a Form_ID for hook_form_FORM_ID_alter?

I want to alter the form for a content type I created for videos. The type is called Videos. How would I use hook_form_alter to alter the form to create the content?
0
votes
1answer
17 views

How to change “Save Draft” value on Webform?

I want to change the button text value from "Save Draft" to "Save". How can I target the button (CSS or custom module works for me)? I used to target forms like this: ...
0
votes
1answer
16 views

How to hide form bulk operations for a specified user role in Drupal 8?

I have a view where I list user's own contents, this contains bulk operations. Users with "add article" permission can see this bulk operations thing but I would like to hide this bulk operations ...
0
votes
1answer
11 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
67 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
23 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
20 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
38 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
135 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
59 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
28 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 ...
1
vote
1answer
31 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
59 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
48 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
18 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
9 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
19 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
45 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
46 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
40 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
94 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
50 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
22 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' ...
1
vote
0answers
25 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 ...
1
vote
0answers
33 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
25 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
23 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
17 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
36 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
28 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?
1
vote
0answers
42 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
26 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
50 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
34 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
44 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
70 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
19 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
26 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 ...