Forms are the primary method for obtaining and acting upon user input in Drupal.
1
vote
2answers
16 views
Adding action to textarea
I am hoping that this enquiry will be a easy one for someone to help shed some light on... I know that in order to create a textarea in Drupal 8 the following code can be used (e.g. render array)
$...
0
votes
0answers
10 views
How do I add an Ajax submit to a Node form?
I have an node form which I am trying to submit via ajax using
$form['actions']['submit']['#ajax'] = [
'callback' => ':submit'
];
The form is submitting properly and the node is getting ...
0
votes
0answers
4 views
Adding Twitter OAuth Signin to Custom Module Template
I'm building my own Custom module for a custom user registration using form function. I want to include the Twitter 'signin' button on it, but I'm a little confused or approach is wrong. I've done all ...
1
vote
0answers
4 views
Additional textbox for adding unique css classes to images uploaded
My project has a custom module that uses the paragraphs module. I have a background image upload field that now requires an additional textbox field to set unique css classes for the individual images ...
0
votes
0answers
13 views
Remove entity from FormStateInterface $form_state
I have a case where the user registration form is submitting two profiles on submit. I only want to save one of them though (based on another dropdown field in the form.)
I can get the values in ...
0
votes
0answers
11 views
Using FormState::getError() in form alter [on hold]
I am altering the user register form and want to add custom validation for password of minimum length to be 8. I want to check that condition when the password and confirm password matches.
I have ...
0
votes
0answers
14 views
drupal 7 defalt form validation throws errors repeatedly
In Drupal 7 defalt form validation throws field required error repeatedly as per my options array size which is loaded from db.
How Can I show only one field required error for radios error
$form['...
1
vote
0answers
16 views
Added fields don't show up at a content creation form
I tried adding location type of field to gather reviewed place's location. I did everything properly and it didn't show up at a creation form, when trying to submit it said I was missing my location ...
0
votes
0answers
13 views
How to display the submitted content from a Form Block on the same page
I am using the Form Block module in order to show the form of the content type "question" below the the content type "page".
By default, the submitted question on that form redirects to its own node....
0
votes
1answer
21 views
#states and #ajax are not working on pop up
I need to get form only with HTML. To do this, I've used delivery callback in hook_menu(). This is my sample code:
function test_menu() {
$items['htmlform'] = array(
'access callback' => ...
1
vote
1answer
17 views
How to add client side validation to form via FAPI?
I can't figure what to add Client Side Validation for form fields.
'#element_validate' => array('_file_generic_settings_max_filesize'),
I also don't know which value to put for different types of ...
1
vote
0answers
15 views
Get the form element from a specific field of a bundle
In Drupal 8, I have a custom entity 'Data' with bundles enabled. I created two new bundle (Data Types) called 'Big Data' and 'Small Data'. I add a textfield to 'Big Data' and a textarea to 'Small Data'...
1
vote
1answer
13 views
Setting the default value of an entity form radio button using hook_form_FORMID_alter
I have written a custom Drupal 7 module which needs to set the value of a radio button of an entityform based on a value queried from the database.
I have tested hook and it is working as i am able to ...
1
vote
1answer
25 views
YAMLFORM Element Settings
I'm using yamlform in my Drupal 8 site and I want to add a new setting (i.e General Settings, Form Display etc) to each of my fields based on if I have a handler attached to my form.
I have used the ...
0
votes
1answer
18 views
Unable to print form element
I am not able to get form element qty twice. I have 2 line item IDs, but I am getting 1 instead of printing qty twice. Please help me out this. This is my code.
function mol_split_delivery_form($form,...
-3
votes
0answers
19 views
How to create an edit and delete function in a custom module? [closed]
I created an add and view function on my module already. But I have problem to do edit and delete function.
Here is my add and view function:
<?php
function form_example_permission() {
return ...
3
votes
1answer
33 views
Remove name attribute - Form API
For PCI compliance reasons, I need to remove the name attribute from a form field.
I have tried:
(1)
$form['field']= array(
'#name'=>'',
)
(2)
$form['field']= array(
'#name'=>false,
...
0
votes
1answer
15 views
How to make taxonomy term checkbox display multicolumn?
I have about 20 items for checkbox. Drupal default checkbox is too long down. How to make it in to column like this?
[ ] list1 [ ] list4 [ ] list7 [ ] list10
[ ] list2 [ ] list5 [ ] list8 [ ] ...
1
vote
0answers
11 views
Should #process callback use #default_value or #value when expanding an element?
Background
The '#process' callback on a form element is called within form_builder(). It can be used to expand an element into sub-elements.
This is how e.g. the 'radios' or 'checkboxes' elements ...
0
votes
1answer
24 views
Invoke function from module in form
I'm trying to port the OpenID module from Drupal 7 to Drupal 8.
I have a form OpenIdLoginForm.php with the following code.
<?php
...
namespace Drupal\openid\Form;
use Drupal\user\Form\...
0
votes
0answers
19 views
How do I refresh form content?
I have been working on a Drupal 8 module that has a form. The form has a drop-down select field with several options. The form also has a text-area fields and a submit button.
Here is how I want the ...
1
vote
1answer
17 views
Save certain registration fields elsewhere in database
This is for Drupal 7. I am trying to write my first real custom module but I'm running into some difficulty and I'm just not sure how to look for my answers.
I've created a new entity for my module (...
0
votes
2answers
18 views
Boolean checkbox in sytems_settings_form
I have written the following code
$form['checking'] = array(
'#type' => 'checkbox',
'#default_value' => variable_get('checking',0),
'#title' => t('title'),
'#required' => ...
-3
votes
0answers
30 views
I want to upload image in theme settings and get its url as a variable !!
I have been searching for a solution to this issue for weeks it seems impossible to do it I tried every solution and nothing, can any one help me.
I am trying to upload a slider image in theme ...
0
votes
0answers
11 views
Update filtered results
I am a drupal noob so please don't be to hard on me.
I have 2 blocks which are shown on the same page, one block contains results from a query and the other block is a form that is used to filter the ...
0
votes
1answer
31 views
Question for overriding twig at custom module [on hold]
How I can override a template in my custom module, for example form-element-label.html.twig?
3
votes
2answers
37 views
Choose node item from list and add to form
I have content type 'Machinery' and I need to create the form for users where they can enter their name, email, phone number and to select some node from a list and attach it to form.
The user can ...
0
votes
0answers
8 views
Popup datepicker icon is submitting form instead of popping up a datepicker
Here is the (abridged and more nicely formatted) markup of my date field:
<div class="form-item webform-component webform-component-date">
[month/day/year components omitted]
<span ...
4
votes
1answer
35 views
How can I set a default value for date field using hook_form_alter
I am new to Drupal. I need to set a default value to a date field. Please anyone help me on this. Thanks.
4
votes
1answer
34 views
valueCallback in custom form element is not invoking itself?
I am creating a custom form element in my custom module. Everything is working fine except the valueCallback function is not invoking itself. I have done it in following way :
Name space
namespace ...
0
votes
0answers
21 views
Multifield with API form? [closed]
Is there an immediate way to create a MultiField with unlimited items with API form?
Now I have to really write a lot of code to do it properly.
5
votes
1answer
73 views
How to make custom fieldset collapsed by default in Drupal 8
In Drupal 7 there was option to have fieldset collapsible or not, and to restrict default state of this form element (collapsed, or uncollapsed). Example:
$form['contact_data'] = array(
'#...
0
votes
0answers
11 views
Require input for optional field select widget
(My own use case is about taxonomy term reference fields. But a more generic answer is welcome.)
A taxonomy term reference field, single value, not required, with a select widget that shows all terms ...
5
votes
2answers
59 views
Clear form fields after AJAX submit
Given:
I am using Drupal 8.
I have a custom "add form" of the custom entity type.
Form has an ajax submission.
Problem:
When I submit form all the values remain in fields.
Expected:
Form fields ...
0
votes
1answer
35 views
How to get field value of form before submit - Drupal 8
I am trying to get the value of group_name field once data entered by user before submitting the form. Then only I can access the db, where the entered data is exist in db or not using query. If ...
0
votes
0answers
32 views
Attached User profile form gets error on save
I had attached my user_profile_form in my custom form and called the custom form by the defining a new path in hook_menu(). The user_profile_form got rendered correctly. But while saving the form I'm ...
0
votes
0answers
18 views
Need to use value of a checkbox in product type to use elseif in tpl file
Building a site in D7.51, inc Drupal Commerce. In my product type I have created a checkbox that asks whether this particular product is a of a certain type yes or no. If the product is of that type, ...
1
vote
1answer
26 views
How to Change the Format of the Email Template Sent with Webforms
Ok, so I have a customer that has a ridiculously long form that individuals need to complete to apply for funding, but the email that is getting sent to our customer as well as each individual is not ...
1
vote
2answers
19 views
what are the different ways to use the variable in many functions within a module?
I want to access a variable changed in one function in another. I tried this with Session and global variables. I need the variable to be persisted across multiple page requests. are there any other ...
1
vote
0answers
28 views
webform submission form altering in drupal 7
I would like to ask a conceptual/architectural question about drupal 7 webform. I have different webforms and submissions of that, I would like to add a textfield to the submissions, so it will allow ...
1
vote
1answer
20 views
how to pass the query parameters as default values in buildForm?
public function buildForm(array $form, FormStateInterface $form_state) {
// in D7 it was : $params = drupal_get_query_parameters();
$form['search_api_fulltext'] = array(
'#type' => 'textfield',...
0
votes
0answers
15 views
what are the different ways to use the variable in many functions within a module? [duplicate]
I want to access a variable changed in one function in another.
I tried this with Session and global variables.
I need the variable to be persisted across multiple page requests.
are there any other ...
0
votes
1answer
36 views
hook form submit being called twice
In the following code custom call back function is being printed twice. How to prevent submit call back function being called twice.
function my_module_form_alter(&$form, &$form_state, $...
0
votes
2answers
21 views
Allow html tags in Form submit button in block plugin
I'm using a block plugin to render a user specified form. I'm retrieving the form like so:
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['template']...
0
votes
1answer
39 views
Submit form after custom submit handler
I'm trying to create my first module which essentially is a visitor sign-in system where each visitor is stored as a custom content type.
The user will be a visitor to our building who's able to ...
0
votes
0answers
12 views
Add JS validation
I'm using Clientside validation in a form, but I need to include a js file just after all validations but before form submit.
Is there any event or something for include this file ?
Thanks !
4
votes
3answers
119 views
Is there any easy way to set the default author for a node being edited to the current author if it is currently anonymous?
The site I am working on has a lot of Anonymous nodes because it is a migration from a system that didn't have a proper user system. Users can claim their articles by going in and editing the node ...
0
votes
0answers
11 views
Hide/unhide based on number of values in multifield
I want a dependent field to be hidden if a dependee has less than three values, and shown if the dependee has three or greater.
So far in my research, I've not seen a way to do this with states or ...
0
votes
2answers
40 views
How do I add a JavaScript file to a form?
I'm trying to add a JavaScript file to a form that I have in a modal. Although I followed the information found here, here, and here, the file doesn't appear in the Network tab of the inspector and ...
0
votes
0answers
13 views
Validation of required entity reference field (putting in text that doesn't match anything passes validation)
Note: I have some more work to do to work out what the actual cause of this issue is. I can't expect anyone to help me debug it until I've done that, but I don't have time to look into it further ...