Problem/Motivation

Is it possible to increase the maxlength value for FAQPage AcceptedAnwser? I've read that you should use tokens to fill the field, but the question and answer is - in my case - a part of the larger body field. There's no official charachter limit for it, so I don't get the restriction.

Proposed resolution

Change from textfield to textarea, similar to https://www.drupal.org/project/schema_metatag/issues/3424050

Comments

fbreckx created an issue. See original summary.

ssaba’s picture

StatusFileSize
new1.27 KB

Here, I have tried this patch for the version 2.5.

stadoom’s picture

Our customer requires to set several Questions and Answers into the metatag using the Pivot option, so it is better not to limit these fields maxLength and change the field type to textfield.
Screenshot
Here is the patch for 3.0 version.

damienmckenna’s picture

Status: Active » Needs work

This is the wrong approach - the parent PropertyTypeBase class shouldn't know about individual tags.

daluxz’s picture

The patches in this issue didn't work for me.

We are using the FaqPage Questions and Answers with quite long tokens like:
- [node:field_paragraphs:entity:field_node_faq:0:entity:title];[node:field_paragraphs:entity:field_node_faq:1:entity:title];[node:field_paragraphs:entity:field_node_faq:2:entity:title];[node:field_paragraphs:entity:field_node_faq:3:entity:title]
- [node:field_paragraphs:entity:field_node_faq:0:entity:field_text_long_answer];[node:field_paragraphs:entity:field_node_faq:1:entity:field_text_long_answer];[node:field_paragraphs:entity:field_node_faq:2:entity:field_text_long_answer];[node:field_paragraphs:entity:field_node_faq:3:entity:field_text_long_answer]
So these fields run out of space very quickly.

I created a new patch in which a new parameter ("long") is added. Whenever a plugin uses this parameter, a textarea is used instead of a textfield, and the maxlength is removed in that case.

See the attached patch.

daluxz’s picture

Status: Needs work » Needs review
phjou’s picture

Patch #5 is working for me.

aadesh.verma’s picture

We can aslo do this by using hook_form_alter()

function your_module_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // If Metatag field is enabled and FAQ/QA Schema is enabled or not.
  if (isset($form['field_metatags']) && isset($form['field_metatags']['widget'][0]['schema_qa_page'])) {
    // Change test fieldtype from textfield to text area for Question - Text field.
    unset($form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['text']['#maxlength']);
    $form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['text']['#type'] = 'textarea';

    // Change test fieldtype from textfield to text area for Question - name field.
    unset($form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['name']['#maxlength']);
    $form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['name']['#type'] = 'textarea';


    // Change test fieldtype from textfield to text area for Accepted Ancwser - text field.
    unset($form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['acceptedAnswer']['text']['#maxlength']);
    $form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['acceptedAnswer']['text']['#type'] = 'textarea';

    // Change test fieldtype from textfield to text area for Suggessted Ancwser - text field.
    unset($form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['suggestedAnswer']['text']['#maxlength']);
    $form['field_metatags']['widget'][0]['schema_qa_page']['schema_qa_page_main_entity']['suggestedAnswer']['text']['#type'] = 'textarea';

  }
}
crisgc’s picture

Thank you to daluxz for patch #5.

Based on it I made a small adjustment since the added "long" = TRUE line in Answer.php was missing the * docblock prefix, which causes Drupal's annotation parser to silently ignore it, resulting in the Answer fields still enforcing the 255 character limit.

Attaching a fixed patch based on #5 with just this one-line correction.

anybody’s picture

Status: Needs review » Needs work

Could you please prepare a MR instead of using patches? We're in 2026 ...