Custom Ajax forms with managed_file form element

1 month 2 weeks ago

We have a form with three fields - where depending on the value of the first select field, we will show the other two form elements - one select field (the options depends on the value of the first select field) and one file upload field.

The issue is that when I upload a file the second select list value is resetting. Because managed_file form element is again calling an ajax function which overrides the value of my first ajax call

Code is below:

public function buildForm(array $form, FormStateInterface $form_state) { $texts = array(); $text_values = db_query("SELECT text_id, title FROM `heritage_text_structure`")->fetchAll(); foreach($text_values AS $key => $value){ $texts[$value->text_id] = $value->title; } $form['text'] = array( '#type' => 'select', '#title' => $this->t('Select the heritage text'), '#required' => TRUE, '#options' => $texts, '#default_value' => isset($form['text']['#default_value'])?$form['text']['#default_value']:null, '#ajax' => array( 'event' => 'change', 'wrapper' => 'text-info', 'callback' => '::_ajax_text_callback', ), ); if(!empty($form_state->getTriggeringElement())) { $description = ''; $text_id = $form_state->getTriggeringElement()['#value']; $labels = db_query("SELECT level_labels FROM `heritage_text_structure` WHERE text_id = :text_id", array(':text_id' => $text_id))->fetchField(); $labels_array = explode(',', $labels); $label_count = count($labels_array); for($i=0; $i<count($labels_array); $i++){ if($i < $label_count-1) $description = $description.$labels_array[$i].', '; else $description = $description.$labels_array[$i]; } $description = $description.', Content, Language'; $csvCount = $label_count + 2; } $form['text_info'] = array( '#type' => 'container', '#prefix' => '<div id="text-info">', '#suffix' => '</div>' ); if(isset($text_id) && $text_id > 0){ $validators = array( 'file_validate_extensions' => array('csv '), ); $form['text_info']['fieldset'] = array( '#type' => 'fieldset', '#title' => $this->t('Select the Target Source'), '#description' => $this->t('Choose the source into which you are importing content'), ); $sources = array(); $source_values = db_query("SELECT id, title FROM `heritage_source_nodes` WHERE text_id = :text_id", array('text_id' => $text_id))->fetchAll(); foreach($source_values AS $key => $value){ $sources[$value->id] = $value->title; } $form['text_info']['fieldset']['sources'] = array( '#type' => 'select', '#title' => $this->t('Select the Source to which content is imported'), '#required' => TRUE, '#options' => $sources, '#default_value' => isset($form['text_info']['fieldset']['sources']['widget']['#default_value'])?$form['text_info']['fieldset']['sources']['widget']['#default_value']:null, ); $form['text_info']['fieldset']['file'] = array( '#type' => 'managed_file', '#title' => t('Upload the Content in CSV format'), '#size' => 20, '#description' => t('CSV file (eg: '.$description.'). Please maintain the order of the fields.'), '#upload_location' => 'public://file_uploads/', '#upload_validators' => $validators, ); $form['text_info']['fieldset']['csv_count'] = array( '#type' => 'hidden', '#value' => $csvCount, ); } $form['actions']['submit'] = array( '#type' => 'submit', '#value' => $this->t('Import Content'), ); return $form; } /** * {@inheritdoc} Map content to the corresponding fields. */ public function submitForm(array &$form, FormStateInterface $form_state) { $text = $form_state->getValue('text'); print("<pre>");print_r($form_state->getValue());exit; } /** * Ajax callback function */ public function _ajax_text_callback(array $form, FormStateInterface $form_state) { return $form['text_info']; }
ktrev

Location taxonomy

1 month 2 weeks ago

I want to add a location to my products/articles in 2 different ways :

-user enters a town (linked to a taxonomy) -> I know how to do it

-user enters a county which is automaticly linked to a state (with taxonomy too) -> I don't know which module do that

In this way,

all users could find all products in a city, in a county or in a state.

The other difficulty is that I want a module which "knows" all country and regions of several countries (actually all European countries).

Tourist

Aggregated CSS & JS files revert to old version

1 month 2 weeks ago

I'm troubleshooting an odd issue on my Drupal 7 site where it seems that old versions of our aggregated CSS & JS files are used some amount of time after a cache clear. How this is playing out is that I'll make some update to our CSS or JS, then clear the cache via drush cc all (I've also used the UI to manually clear the cache). I get an updated version of the CSS / JS for a while. At some point (typically I've noticed it a few hours later), the page serves the old version of the aggregated file.

I've pulled mysqldumps of the site, and can see that the values in the variable table for drupal_css_cache_files, for example, contain a reference to the old aggregate rather than the new.

I found this issue on drupal.org (and I'm not sure it's exactly the same thing), but one of the suggestions involves deleting all files in <root>/cache, which I don't have. Would this be the same as deleting the files in sites/default/files/js/?

Another part of this that may or may not be related is that I see in my site logs "page not found" requests for old aggregated files that don't exist anymore.

I'm hitting a wall in troubleshooting, since it seems like the actual database value for the new aggregated file is being reverted. Anyone know what might be going on here?

nkanderson

Add a class the the form element (tag) of the search block form

1 month 2 weeks ago

How do I add a class to the form element of the search block form?

I mean, add a class to this element:

<form action="/search/node" method="get" id="search-block-form" accept-charset="UTF-8" data-drupal-form-fields="edit-keys"></form>

I've tried:

function mytheme_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'search_block_form') { $form['#attributes'] = array('class' => array('abc')); } }

and

function mytheme_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'search_block_form') { $form['#attributes']['class'][] = 'abc'; } }

I've tried:

function mytheme_preprocess_form(&$variables) { if ($variables['element']['#form_id'] == 'search_block_form') { $variables['element']['#attributes'] = array('class' => array('xyz')); } }

I've looked into altering core/modules/system/templates/form.html.twig, which does not look like the way to go.

I'm using the Bootstrap theme as my base.

dbj44

Views Pager Add rel="nofollow to ALL Pager Links

1 month 2 weeks ago

In Drupal 7 I am trying to add rel="nofollow" to ALL of the pager links in views. The closest I have got is to add the nofollow to next links, but I want it to include previous pages as well as "First" and "Last".

P.S. We specifically want the rel="nofollow" attribute to all pager links, we are not looking for other solutions (noindex, block with robots.txt, or rel=next/prev).

This is the code I am currently using:

function mytheme_pager_next($variables) { $text = $variables['text']; $element = $variables['element']; $interval = $variables['interval']; $parameters = $variables['parameters']; global $pager_page_array, $pager_total; $output = ''; // If we are anywhere but the last page if ($pager_page_array[$element] < ($pager_total[$element] - 1)) { $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array); // If the next page is the last page, mark the link as such. if ($page_new[$element] == ($pager_total[$element] - 1)) { $output = theme('pager_last', array('text' => $text, 'element' => $element, 'parameters' => $parameters,'attributes'=>array('rel'=&gt;'nofollow'))); } // The next page is not the last page. else { $output = theme('pager_link', array('text' => $text, 'page_new' => $page_new, 'element' => $element, 'parameters' => $parameters,'attributes'=>array('rel'=>'nofollow'))); } } return $output; }
Haz

How to provide theme suggestions based on display mode of media for file video

1 month 2 weeks ago

I want to have a seperate template for Video Media Field to have a play icon on the center of the video. But the file video template doesn't have a suggestion based on Media Video view mode.

I tried to add it in hook_preprocess_file_video in .theme file, but there is no view mode in the variables. How do we provide a template based on view mode, I saw that there is a way to add suggestions using HOOK_theme_suggestions_file_video_alter, but there also I gont get the display mode?

Zuhair

How do I render form fields in my custom.tpl.php template?

1 month 2 weeks ago

Here's my dilemma, I built a custom form-based module that allows a user to vote on a future conference location but I'm having a issue printing or rendering my form fields to have them display in my custom block template.

eventvoting.module

<?php /** * @file * Title : Drupal 7 Event Voting form in a block pattern with template file * Author : Kenyon M. Johnston * * Web application form that allows site visitors to vote on what city they * would like to see host their favorite event next year. */ /** * Implmentation of hook_permission() */ function eventvoting_permission(){ return array ( 'Administer event voting form' => array( 'title' => t('Administer event voting form'), 'description' => t('Allows users to implement custom css class for the Event Voting Form module'), ) ); } /** * Implements hook_block_info(). */ function eventvoting_block_info() { $block['eventvoting_block'] = array( 'info' => t('Event Voting Form Block'), 'cache' => DRUPAL_CACHE_PER_ROLE, ); return $block; } /** * Implementation of hook_block_view() */ function eventvoting_block_view($delta = '') { $block = array(); switch ($delta) { case 'eventvoting': $block['subject'] = t(''); $block['content'] = array( '#theme' => 'eventvoting', '#vote_event_name' => variable_get('event_name'), '#vote_city' => variable_get('city'), '#vote_name' => variable_get('name'), '#vote_email' => variable_get('email'), '#vote_submit' => variable_get('submit'), ); break; } return $block; } /* * Implements hook_theme */ function eventvoting_theme(){ return array ( 'eventvoting' => array ( 'arguments' => array( 'vote_event_name' => NULL, 'vote_city' => NULL, 'vote_name' => NULL, 'vote_email' => NULL, 'vote_submit' => NULL, ), // Use a template file called eventtheme.tpl.php 'template' => 'theme/eventtheme', ), ); } /** * Implements hook_menu(). */ function eventvoting_menu() { $items['event-voting-form'] = array( 'title' => 'Event Voting Form', 'page callback' => 'drupal_get_form', 'page arguments' => array('eventvoting_form'), // Use the default/standard site configuration permission. 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Creates/returns a form to configure the block's variables. * * @param array $form * @param array $form_state * @return array */ function eventvoting_form($form, &$form_state) { $form['event_name'] = array( '#title' => t('Select an event:'), '#type' => 'textfield', '#default_value' => variable_get('event_name'), '#required' => TRUE, '#weight' => 0, ); $form['city'] = array( '#title' => t('Vote for a city:'), '#type' => 'textfield', '#default_value' => variable_get('city'), '#required' => TRUE, '#weight' => 0, ); $form['name'] = array( '#title' => t('Your name:'), '#type' => 'textfield', '#default_value' => variable_get('name'), '#required' => TRUE, '#weight' => 0, ); $form['email'] = array( '#title' => t('Your email:'), '#type' => 'textfield', '#default_value' => variable_get('email'), '#required' => TRUE, '#weight' => 0, ); $form['save'] = array( '#type' => 'submit', '#value' => t('Vote'), ); return $form; } **<h2><strong>eventheme.tpl.php (inside the "theme" directory)</strong></h2>** <?php /* * File : eventtheme.tpl.php * Title : Drupal 7 Event Voting Location form in a block pattern with template file * Author : Kenyon M. Johnston * */ ?> <div class="event-voting-form"> <form> <h2>Vote for Next Year's Event</h2> <div id="vote_event_name"> <?php print $vote_event_name; ?> </div> <div id="data-fieldset"> <div id="vote_city"> <?php print $vote_city ?> </div> <div id="vote_name"> <?php print $name ?> </div> <div id="vote_email"> <?php print $email ?> </div> <div id="vote_submit"> <?php print $submit ?> </div> </div> <?php print drupal_render_children($form); ?> </form> </div>

My goal is to render my fields of choice. The theme renders in the block but not the fields,

This has been racking my brain for a few hours now, any help and assistance would be GREATLY appreciated.

Kenyon Johnston

Organic-Groups multisite architecture

1 month 2 weeks ago

I have a task to build a series of websites all related to the same core business.

Initially, I was going to build each one as a separate website. Later however, I was told the sites have to be able to share content which changed my plans.

Going by the logic that the easiest way to build multiple Drupal websites which share content is to build one site and make it work and appear as many.

So, I decided to build the site in Organic Groups but I have the following functionality challenges.

  1. How can I direct unique URLs to individual Groups on my site. I:E configuring www.mysite.co.uk to visit Group#1 and www.mysite.com to visit Group#2 etc

  2. Is there a way to create content on the Drupal site which can optionally be shared/posted to one or more of my Groups? The idea is to create content on the primary 'website' and the same content displays in the Groups/'sub-sites'.

I would appreciate any suggestions.

Thanks.

sisko

How to retrieve taxonomy term name in url instead of id in a drupal view?

1 month 2 weeks ago

I'm currently working on Drupal 10 and utilizing Views with filter criteria. However, when I apply filters to my view, it shows the ID of the taxonomy term instead of its name. How can I ensure that it displays the name of the term instead of the ID? Essentially, I want it to show something like 'keys=&theme=operateur' instead of 'keys=&theme=2'.

I tried configuring contextual filters, but nothing seems to work.

lucia

add Solr search box in views filter

1 month 2 weeks ago

I have succesfully installed solr and it is working fine, but my main search in my drupal site is based on views exposed filters, is there a way to add the solr search in views filters, so it interacts with them?

I am using views to setup an advanced search, by exposing filters, i want to add one that uses solr, so in total solr search is used together with views filter and i get corresponding results from files too.

Jonid Bendo

sort comments descending programmatically

1 month 2 weeks ago

I want to sort all comment descending programmatically, I found this Comments sorted by oldest first but I dont want use those modules or views solution.
anybody know how can I sort comment descending programmatically?
I means comments in below node(contents) , first ideal is get comments related to node by query and set orderby DESC but everything show reversed in thread mode, replies come above comment !!!.

Yuseferi

Import CSV file from S3 Bucket

1 month 2 weeks ago

Using s3 file system & feed import module. Issue is the fetching of csv file from s3 working... says no file or folder detected ... have the folder under s3://public/repo.csv and had read/write permission.

When running import, it will have a no file / directory found.

Bilyotoy

Pay-Per-Node Functionality

1 month 2 weeks ago

My client would like a content type that has to be purchased by a registered user on a node-per-node basis.

A previously registered user will see a view with the available content they can purchase and then that user can purchase individual nodes. These nodes that have been purchased will also appear in a My Library view as well.

I have found multiple tutorials on how to do this via D7; however, I can't seem to find anything that shows how to do this on D8.

Can Drupal 8's Commerce Module do this out of the box or will I need to install additional modules to reach this functionality.

I am trying to find the right configurations of Products, Orders, and Stores but so far to no avail.

GradoniusTheWise

How to remove unwanted div from view rendered block?

1 month 2 weeks ago

In D8 I've created a view and assigned it into a block,

  1. I've created corresponding template for both view and block.
  2. Most of the unwanted addition of div's and classes has been removed.

But the following empty div is still there in the rendered HTML

<div class="js-view-dom-id-e0cc1fe812f18c9b5d6660b04594c41b597ae5ee9b28cf43f718dc43b43a2f42">

Anyone experienced the same issue?

Nikhil

Taxonomy cache invalidate

1 month 2 weeks ago

Drupal cache Drupal 10.

I'm trying to invalidate the cache, when there's a new taxonomy term is added.

Here's my code:

$build = [ '#cache' => [ 'contexts' => ['taxonomy_list:city'], ] ]; return (new ResourceResponse($data, 200))->addCacheableDependency(CacheableMetadata::createFromRenderArray($build));

When I added a new city, the Cache is still HIT. I want to refresh the cache when a new city is added to the taxonomy list.

mana

Use a field's values in database to populate an exposed filter's options

1 month 2 weeks ago

I have a content type with a field named year (integer).

In a view, I'd like to expose this field to the user as a filter.

Instead of the default text boxes, I want to populate select lists with the values in the database for that field. Then the user will just have to click to select.

My php code writing is on copy-paste level.

I am using D7.

turzifer

HTTPS with and without www

1 month 3 weeks ago

I have drupal 8 based website implemented.

global $base_url; is used in two different modules.

  • Module-1:

    $content .= $base_url .'/user/role/1';

    it gives the URL pattern as: https://www.example.com/user/role/1

  • Module-2:

    $content .= $base_url .'/services';

    it gives the URL pattern as: https://example.com/services

Are there any settings or configs that need to be set up to get the same pattern when I call the $base_url?

.htaccess file

# # Apache/PHP/Drupal settings: # # Protect files and directories from prying eyes. <FilesMatch "\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$"> <IfModule mod_authz_core.c> Require all denied </IfModule> <IfModule !mod_authz_core.c> Order allow,deny </IfModule> </FilesMatch> # Don't show directory listings for URLs which map to a directory. Options -Indexes # Set the default handler. DirectoryIndex index.php index.html index.htm # Add correct encoding for SVGZ. AddType image/svg+xml svg svgz AddEncoding gzip svgz # Most of the following PHP settings cannot be changed at runtime. See # sites/default/default.settings.php and # Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be # changed at runtime. # PHP 5, Apache 1 and 2. <IfModule mod_php5.c> php_value assert.active 0 php_flag session.auto_start off php_value mbstring.http_input pass php_value mbstring.http_output pass php_flag mbstring.encoding_translation off # PHP 5.6 has deprecated $HTTP_RAW_POST_DATA and produces warnings if this is # not set. php_value always_populate_raw_post_data -1 </IfModule> # Requires mod_expires to be enabled. <IfModule mod_expires.c> # Enable expirations. ExpiresActive On # Cache all files for 2 weeks after access (A). ExpiresDefault A1209600 <FilesMatch \.php$> # Do not allow PHP scripts to be cached unless they explicitly send cache # headers themselves. Otherwise all scripts would have to overwrite the # headers set by mod_expires if they want another caching behavior. This may # fail if an error occurs early in the bootstrap process, and it may cause # problems if a non-Drupal PHP file is installed in a subdirectory. ExpiresActive Off </FilesMatch> </IfModule> # Set a fallback resource if mod_rewrite is not enabled. This allows Drupal to # work without clean URLs. This requires Apache version >= 2.2.16. If Drupal is # not accessed by the top level URL (i.e.: http://example.com/drupal/ instead of # http://example.com/), the path to index.php will need to be adjusted. <IfModule !mod_rewrite.c> FallbackResource /index.php </IfModule> # Various rewrite rules. <IfModule mod_rewrite.c> RewriteEngine on # Set "protossl" to "s" if we were accessed via https://. This is used later # if you enable "www." stripping or enforcement, in order to ensure that # you don't bounce between http and https. RewriteRule ^ - [E=protossl] RewriteCond %{HTTPS} on RewriteRule ^ - [E=protossl:s] # Make sure Authorization HTTP header is available to PHP # even when running as CGI or FastCGI. RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Block access to "hidden" directories whose names begin with a period. This # includes directories used by version control systems such as Subversion or # Git to store control files. Files whose names begin with a period, as well # as the control files used by CVS, are protected by the FilesMatch directive # above. # # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is # not possible to block access to entire directories from .htaccess because # <DirectoryMatch> is not allowed here. # # If you do not have mod_rewrite installed, you should remove these # directories from your webroot or otherwise protect them from being # downloaded. RewriteRule "/\.|^\.(?!well-known/)" - [F] # If your site can be accessed both with and without the 'www.' prefix, you # can use one of the following settings to redirect users to your preferred # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option: # # To redirect all users to access the site WITH the 'www.' prefix, # (http://example.com/foo will be redirected to http://www.example.com/foo) # uncomment the following: # RewriteCond %{HTTP_HOST} . # RewriteCond %{HTTP_HOST} !^www\. [NC] # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # # To redirect all users to access the site WITHOUT the 'www.' prefix, # (http://www.example.com/foo will be redirected to http://example.com/foo) # uncomment the following: # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301] # Modify the RewriteBase if you are using Drupal in a subdirectory or in a # VirtualDocumentRoot and the rewrite rules are not working properly. # For example if your site is at http://example.com/drupal uncomment and # modify the following line: # RewriteBase /drupal # # If your site is running in a VirtualDocumentRoot at http://example.com/, # uncomment the following line: # RewriteBase / # Redirect common PHP files to their new locations. RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR] RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild.php) RewriteCond %{REQUEST_URI} !core RewriteRule ^ %1/core/%2 [L,QSA,R=301] # Rewrite install.php during installation to see if mod_rewrite is working RewriteRule ^core/install.php core/install.php?rewrite=ok [QSA,L] # Pass all requests not referring directly to files in the filesystem to # index.php. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] # For security reasons, deny access to other PHP files on public sites. # Note: The following URI conditions are not anchored at the start (^), # because Drupal may be located in a subdirectory. To further improve # security, you can replace '!/' with '!^/'. # Allow access to PHP files in /core (like authorize.php or install.php): RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$ # Allow access to test-specific PHP files: RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php # Allow access to Statistics module's custom front controller. # Copy and adapt this rule to directly execute PHP files in contributed or # custom modules or to run another PHP application in the same directory. RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$ # Deny access to any other PHP files that do not match the rules above. # Specifically, disallow autoload.php from being served directly. RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F] # Rules to correctly serve gzip compressed CSS and JS files. # Requires both mod_rewrite and mod_headers to be enabled. <IfModule mod_headers.c> # Serve gzip compressed CSS files if they exist and the client accepts gzip. RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.css $1\.css\.gz [QSA] # Serve gzip compressed JS files if they exist and the client accepts gzip. RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.js $1\.js\.gz [QSA] # Serve correct content types, and prevent mod_deflate double gzip. RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1] RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1] <FilesMatch "(\.js\.gz|\.css\.gz)$"> # Serve correct encoding type. Header set Content-Encoding gzip # Force proxies to cache gzipped & non-gzipped css/js files separately. Header append Vary Accept-Encoding </FilesMatch> </IfModule> </IfModule> # Various header fixes. <IfModule mod_headers.c> # Disable content sniffing, since it's an attack vector. Header always set X-Content-Type-Options nosniff # Disable Proxy header, since it's an attack vector. RequestHeader unset Proxy </IfModule>
DrupBha

How can I dynamically disable a single required field from validation in a form?

1 month 3 weeks ago

This is an extension of this question:

Need help with AJAX callback function for text field validation in form_alter

I have a form with a Username autocomplete field (txn_user). The editors want to be able to enter a UID (txn_userid) as an alternative way of specifying the User for the form. They want to be able to enter the UID and skip the Username field altogether.

So in my form validation function, I want to be able to disable the required property (and all other validation) of the Username field during a Submit IF the editor typed in a UID field. In other words: the UID field should 'short-circuit' the Username field.

This is what I have so far (which doesn't work, obviously). Or do I need to do this via AJAX or straight JS?

function _validate_add_userpoints_userid(&$form, &$form_state) { $values = $form_state['values']; if( $values['txn_userid'] ) { $newuser = user_load($values['txn_userid']); if( ! $newuser) { form_set_error('txn_userid', 'You have entered an invalid UID. Either leave this blank and select a Username or enter a valid UID'); } else { // this part works... the User Name is properly assigned. $form['txn_user']['#value'] = $newuser->name; $form_state['values']['txn_user'] = $newuser; $form_state['input']['txn_user'] = $newuser->name; // this part doesn't work... the User Name field is still required on submit. $form['txn_user']['#disabled'] = TRUE; $form['txn_user']['#ajax_processed'] = TRUE; $form['txn_user']['#required'] = FALSE; $form['txn_user']['#needs_validation'] = FALSE; unset($form['txn_user']['#process']); } }

}

jchwebdev
Checked
8 hours 27 minutes ago
most recent 30 from drupal.stackexchange.com
Subscribe to Drupal StackExchange feed