惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
T
The Blog of Author Tim Ferriss
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
量子位
I
InfoQ
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
Google Developers Blog
J
Java Code Geeks
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
V
V2EX
腾讯CDC
P
Proofpoint News Feed
A
About on SuperTechFans
爱范儿
爱范儿
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Añadir un enlace a un campo booleano
oskar calvo · 2026-06-12 · via DEV Community

oskar calvo

Buenas, esto es algo que he tenido que sacar esta semana, algo que no esta resuelto en ningún módulo ni contribuido ni del core, no he hecho un módulo, únicamente un simple form_alter para resolverlo.

Contexto: se ha creado un tipo de contenido (nodo) llamado incidencia para que los usuarios anónimos puedan dar de alta incidencias, se ha creado un nodo y no un webform porque esas incidencias tendrán estados, comentarios de las personas que tienen que resolverlas y supervisarlas, etc.

Uno de los campos de este contenido es un cambo booleano tipo "Acepto condiciones y política de privacidad" y se quería añadir un enlace en la palabra "política de privacidad" para que llevase al nodo de política de privacidad.

aquí el código:

  /**
   * Privacy policy link.
   */
  #[Hook('form_alter')]
  public function privacy_policy_link(array &$form, FormStateInterface $form_state, $form_id): void {

    if ($form_id !== 'node_issue_form') {
      return;
    }


     // NOTE: Para una segunda iteración hacer un formulario para elegir cual es el nodo de politica de privacidad y desde el hook_form_alter llamarlo para no tener a fuego la ruta.

    $url = Url::fromUserInput('/politica-privacidad');
    $form['field_issue_privacy_policy']['widget']['value']['#title_display'] = 'after';
    $form['field_issue_privacy_policy']['widget']['value']['#title'] = t(
      'Acepto la <a href=":url" target="_blank">política de privacidad</a>',
      [':url' => $url->toString()]
    );
  }