This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Setting a Date field programmatically with Timezone information.

This is not a question, just a place to put some information which I could not find for the love of god anywhere and ChatGPT sent me down a wrong rabbit hole. Hopefully it saves somebody else some time? :-)

$new_datetime = gmdate('c', strtotime('+10 days'));

$date_time_obj = new DrupalDateTime($new_datetime, new \DateTimeZone('Pacific/Apia'));

$entity->set('your_date_field', ['value' => $date_time_obj->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT), 'timezone' => 'Pacific/Apia']);

Webform generic_element option?

This is a knowledge question because I've never worked with webforms before and am curious about a finding.

separating uploaded files list and upload widget

Hi , i have content type named: "exams_and_assignments" and a field named: "field_exams_assignments_files"

i want to give permission to all teachers to add files to the node, but prevent them to edit other's uploaded files.

so, i made a custom module to disable field values in dispaly form : 

Best method to share user sessions table (d10/11)

Hello,

I need to share sessions table between 2 sites (same domain, eg. .mysite.com). In drupal 7, i have already build this in settings.php.

I have created a new database for this.

On drupal 10/11, this seems different, because we cannot achieve this on the database definition in the settings.php. But maybe that's a mistake.

Should I use another method, create a custom service for this?

Thanks for your help.

iFrme form validation

Hi there,

Could someone please guide me on how to validate forms within an iframe? Specifically, I am working with forms such as:

"entity-browser-browse-files-modal-form"
"entity-browser-browse-files-form"

function hook_form_alter(&$form, &$form_state, $form_id) {
 // Add Custom validation
}

I would appreciate any advice or examples on how to properly handle form validation inside an iframe context.

Thank you in advance for your help!

Best way to transition roles and permissions from development to production

Hello all!  While developing our Drupal site, we have set up some additional custom roles and assigned permissions to these roles.  As developers, we configure these incrementally and test on our development environment. Once this is tested and working, what is the best way to transfer all these custom roles and assigned permissions to test and production environments, such that the site administrators do not need to go into the Drupal administration page manually to re-configure and assign all these custom roles and assigned permissions? Should I build some custom module to handle this?

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions