πŸ‡ΊπŸ‡ΈUnited States @Cayenne

Account created on 18 November 2006, over 17 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States Cayenne

I am having the same issue and am needing to tell customers to log out. But that's pretty ugly as solutions go.

πŸ‡ΊπŸ‡ΈUnited States Cayenne

I just updated to the latest version (10.2.5) and I am still experiencing this bug

Simple view of nodes, add a contextual filter by ID fails, with the dreaded "The submitted value in the Profile type element is not allowed." problem.

πŸ‡ΊπŸ‡ΈUnited States Cayenne

I created a simple test case

function crtx_cruises_form_alter(&$form, $form_state, $form_id){
$form['testme'] = ['#type'=>'textfield', '#title'=>"I am a test"];
$submit_handlers = $form_state->getSubmitHandlers();
$submit_handlers[] = 'crtx_test_submit';
$form_state->setSubmitHandlers($submit_handlers);
$form['actions']['submit']['#submit'][]= 'crtx_test_submit';

}

function crtx_test_submit($form, &$form_state) {
dsm($form_state->getValues());

}

And in this case, the values entered in the test textfield came through just fine!  Thank you for the hint.

Sorry for the distraction.

πŸ‡ΊπŸ‡ΈUnited States Cayenne

I'll generate a cleaner test function.

I failed to notice how the formatting collapsed.

πŸ‡ΊπŸ‡ΈUnited States Cayenne

Thanks for being willing to take a look

This is code that modifies the add to cart form

It fetches the webform that is associated with the product and replicates its fields in the "add to cart form" so that I can pre-fill a webform submission with the fetched data.

function crtx_cruises_form_alter(&$form, $form_state, $form_id){
switch($form_id){
case 'node_crtx_participant_edit_form':
$field = 'field_crtx_participant_webform';
break;
case 'crtx_boat':
$field = 'node_crtx_boat_edit_form';
break;
default:
return;
}
$node=$form_state->getformObject()->getEntity();
$data = crtx_cruises_what_it_is_on($node);
$cruise_id = $data['cruise'];
$cruise = Node::load($cruise_id);
if(isset($cruise->$field) ){ // test for a relevant webform
$webformid = $cruise->$field->target_id;
$webfields = crtx_cruises_get_webform_tags($webformid); //get the fields of the webform
$webdata = crtx_cruises_webform_submission_data($node, $webformid);
$form['crtx_webformid']=['#type'=>'hidden','#value'=>$webformid];
$form['crtx_webform_sid']=['#type'=>'hidden','#value'=>$webdata['#sid']];
foreach($webfields as $tag=>$field){
$form[$tag]=$field;
$form[$tag]['#value'] = $webdata[$tag]??'';
}
}
$submit_handlers = $form_state->getSubmitHandlers();
$submit_handlers[] = 'crtx_cruises_webform_update_from_node'; // this is the handler that looks for the data in the added fields
$form_state->setSubmitHandlers($submit_handlers);
$form['actions']['submit']['#submit'][]= 'crtx_cruises_webform_update_from_node';
}

Here is the routine that fetches the submission data

function crtx_cruises_webform_update_from_node($form, &$form_state) {
// your code
$raw = $form_state->getUserInput(); //USING THIS. It is unsanitized
$webformid = $raw["crtx_webformid"]; // coded on the form
$sid = $raw["crtx_webform_sid"]; // " " " "
if(!$sid){ // create webform if it don't exist
$source_id = $form_state->getformObject()->getEntity()->id();
$submission = crtx_webform_submission_create($webformid, $source_id);
$sid = $submission->id();
}
crtx_webform_submission_update($webformid, $sid,$raw);
}

πŸ‡ΊπŸ‡ΈUnited States Cayenne

In my case, I am using these inputs to feed a webform which, I am informed, does the sanitization. But that is certainly a potential risk.
 

If that is not the case, or for users not inputting into some sanitizing module, do you have a better answer?  I'd prefer that as well!

πŸ‡ΊπŸ‡ΈUnited States Cayenne

I am adding several fields to a node edit form using hook_form_alter, but as the OP also suffered, the inputs to those fields are invisible to the submitted form_state.

To be more precise, the form elements with their original values are there, but the values that I enter have no effect.  Values entered in the form_alter added fields, however, are not respected.

πŸ‡ΊπŸ‡ΈUnited States Cayenne

Thank you for this. It worked for me. Simple database search and delete.

πŸ‡ΊπŸ‡ΈUnited States Cayenne

Cayenne β†’ created an issue.

πŸ‡ΊπŸ‡ΈUnited States Cayenne

Thanks for the subtheme suggestion. Many themes have an express function to allow modest tweaks. Others do not. I was hoping this one did!

πŸ‡ΊπŸ‡ΈUnited States Cayenne

Cayenne β†’ created an issue.

Production build 0.69.0 2024